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.

Bug 72819 - Integrate JUnit 4 completely
Summary: Integrate JUnit 4 completely
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 5.x
Hardware: All All
: P1 blocker (vote)
Assignee: Marian Petras
URL:
Keywords:
Depends on: 76408 98328
Blocks: 89593
  Show dependency tree
 
Reported: 2006-02-19 20:57 UTC by dynamite
Modified: 2007-03-20 13:46 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dynamite 2006-02-19 20:57:30 UTC
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).
Comment 1 Marian Petras 2006-02-20 10:21:03 UTC
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.
Comment 2 Masaki Katakai 2006-12-18 04:33:16 UTC
Hi,

Is there any plan to integrate JUnit4 into NetBeans 6.0 ?
Comment 3 Marian Petras 2007-01-10 22:06:21 UTC
There is no such plan yet.
Comment 4 dynamite 2007-01-11 08:53:47 UTC
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.
Comment 5 Marian Petras 2007-03-19 11:29:14 UTC
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.
Comment 6 Masaki Katakai 2007-03-20 07:01:14 UTC
Great work! Thanks!
Comment 7 Masaki Katakai 2007-03-20 07:25:39 UTC
Btw, I could see only JUnit 3.x javadoc in library. Any plan to put JUnit 4
javadoc too?