This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I have tried the just-released JUnit 4 with NetBeans 5.0 and thought I would share my observations. JUnit 4 seems to already be quite useable in NetBeans 5 with some fairly obvious steps. It is currently possible to use JUnit 4 in NetBeans by following the CookBook. The TestCase constructor is replaced by a suite method that returns a JUnit4TestAdapter, test methods are given a @Test annotation and a number of imports and static imports need to be made. Additionally, the JUnit library needs to be replaced by a JUnit4 library that references the JUnit 4 jars, source and docs. This all works ... almost. 1. For a failed test the stack trace contains all junit entries. This is presumably because junit packages now begin org.junit rather than just junit. 2. Test method names are not picked up when all tests pass and are all displayed as 'unknown'. 3. For a complete integration a project JUnit 4 templates would be needed and the JUnit 4 library. I guess the project would need an option to indicate whether JUnit 4 was to be used (naturally, should only be possible for JDK 5+ projects).
dynamite, thank you for the summary. Jaroslav Tulach and I already work on integrating JUnit 4 support into NetBeans. We have a summary on <http://junit.netbeans.org/doc/junit4.html>. I will add a note about the issue with stacktraces, thank you for pointing it out.
Hi, Is there any plan to integrate JUnit4 into NetBeans 6.0 ?
There is no such plan yet.
JUnit 4 support in NB6 is better than previous versions since NB moved to Ant 1.7. Ant 1.7 comes with JUnit4 support. I have noticed that test method names are now picked-up. Missing is the JUnit 4 jar and a version of the JUnit source templates for JUnit 4.
This is now implemented - JUnit 4.1 library is on the classpath, templates for JUnit 4.1 tests are available and both JUnit 3.x and JUnit 4.x tests can be executed. See issue #76408 for the list of modified files.
Great work! Thanks!
Btw, I could see only JUnit 3.x javadoc in library. Any plan to put JUnit 4 javadoc too?