Netbeans:“运行->”测试项目”不做任何事
我有很多 JUnit 测试,它们都是由 Netbeans 的助手创建的(所以没有定制)。我可以通过执行“测试文件”(Ctrl+F6) 来手动运行每个测试。
但是,当我使用“运行 -> 测试项目”时,显示消息“未执行测试”。
我是否必须在某处注册每个 JUnit 测试?
或者这里可能有什么问题?
在此之前,输出窗口中将出现以下内容:
init:
Deleting: /MY-WORK/my.data.adv/build/built-jar.properties
deps-jar:
Updating property file: /MY-WORK/my.data.adv/build/built-jar.properties
my.commons.init:
my.commons.deps-jar:
Updating property file: /MY-WORK/my.data.adv/build/built-jar.properties
my.commons.compile:
Copy libraries to /MY-WORK/my.commons/dist/lib.
my.commons.jar:
my.data.init:
my.data.deps-jar:
Updating property file: /MY-WORK/my.data.adv/build/built-jar.properties
my.data.compile:
Copy libraries to /MY-WORK/my.data/dist/lib.
my.data.jar:
compile:
compile-test:
test-report:
test:
BUILD SUCCESSFUL (total time: 0 seconds)
编辑
项目类型为“类库”,
build.xml 中无自定义配置
使用。也许需要提及的是,该项目是旧的(使用 6.7 之前的某些 Netbeans 版本创建的)。
也许需要提及的是,
I have many JUnit tests, which are all created by Netbeans' assistant (so nothing customized). I can run every test manually by doing "Test File" (Ctrl+F6).
But when I use "Run -> Test Project", the message "No Tests executed" is displayed.
Do I have to register every JUnit test somewhere?
Or what could be the problem here?
Before that, following appears in the output window:
init:
Deleting: /MY-WORK/my.data.adv/build/built-jar.properties
deps-jar:
Updating property file: /MY-WORK/my.data.adv/build/built-jar.properties
my.commons.init:
my.commons.deps-jar:
Updating property file: /MY-WORK/my.data.adv/build/built-jar.properties
my.commons.compile:
Copy libraries to /MY-WORK/my.commons/dist/lib.
my.commons.jar:
my.data.init:
my.data.deps-jar:
Updating property file: /MY-WORK/my.data.adv/build/built-jar.properties
my.data.compile:
Copy libraries to /MY-WORK/my.data/dist/lib.
my.data.jar:
compile:
compile-test:
test-report:
test:
BUILD SUCCESSFUL (total time: 0 seconds)
EDIT
The project type is "class library", no custom configurations in
build.xml
are used.Perhaps it is relevant to mention, that the project is old (created with some Netbeans version prior to 6.7).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于我提交了生成答案所需的正确线索,我认为我应该为其添加一点价值...
如果您使用 NetBeans 创建一个 Java-> 类库项目,您可以创建一个与每个项目关联的单元测试项目源包中的类。您只需在项目资源管理器中右键单击该类即可。
如果您要为项目创建“第一个测试”,IDE 允许您在 JUnit 3 和 JUnit 4 之间进行选择。
当您为 abcNewClass 创建测试时,NetBeans 将允许您将测试命名为任何您想要的名称,并将测试放在任意位置。包您想要的...大多数时候,您不想更改对话框中显示的默认值(abcNewClassTest)。在 NetBeans 6.9 版本中,如果您要创建的测试名称没有“Test”作为后缀,则会出现警告。
如果您创建的测试类名称不以“Test”结尾,则当您对项目使用“测试”操作时,仍然可以运行它们。您只需从“正常”测试类中触发它们即可。
Since I submitted the correct clue necessary to generate an answer, I figure that I should add a bit of value to it...
If you create a Java->Class Library project with NetBeans, you can create a unit test associated with each of the classes in your project's Source Packages. You just need to right-click on the class in the Projects explorer.
If you are creating the 'first test' for a project, the IDE lets you choose between JUnit 3 and JUnit 4.
When you create a test for a.b.c.NewClass, NetBeans will allow you to name the test anything you want and put the test in any package you want... most of the time, you do not want to change the defaults that appear in the dialog (a.b.c.NewClassTest). In NetBeans 6.9 builds, a warning will appear if the name of the test you are about to create does not have "Test" as its suffix.
If you create test class names that do not end with "Test", you can still get them to run when you use the Test action on a project. You just have to trigger them from a 'normal' test class.
感谢用户
vkraemer
!解决方案是:只有名称以
Test
结尾的 JUnit 测试才会运行。build-impl.xml
的部分证明了这一点:Thanks to the user
vkraemer
!The solution is: Only JUnit tests are run when their name ends with
Test
.Section from
build-impl.xml
proves it:如果您使用 Maven,您可能需要检查 pom.xml 上的 Surefire 插件
If you are using maven, you might want to check your surefire plugin on pom.xml
我的测试工作正常,然后停止了,只显示:
问题是
VM Options:
中-D
后面有多余的空格。这导致了问题:这解决了它:
My tests were working then they stopped, just displaying:
The problem was an extra space in the
VM Options:
after the-D
. This caused problems:and this fixed it: