Why do certain JUnit tests not get executed in NetBeans and/or Hudson?
When I right click a project in NetBeans and choose Test, certain unit tests aren't running. If I right click the .java file that contains the unit tests and choose Test File开发者_开发知识库, the unit tests do run. Also I have this project in Hudson CI and those same unit tests don't get run.
Only the tests in classes named after a class in the project with the suffix Test will get executed. For example, tests in unit test class FooTests will never run (suffix isn't exactly Test). Tests in unit test class FooTest will run only if the project has a class named Foo.
It would be nice to know why it has to be this way...
Edit: I was only partially correct in my initial diagnosis. I found this forum post which explains that it is a NetBeans/JUnit issue. The NetBeans ant target that runs tests only looks for tests in all files matching the mask: *Test.java. You can see this in the -do-test-run target in build-impl.xml in the nbproject folder. Thus you just have to make sure all unit test classes end with the suffix Test and you should be fine.
精彩评论