JUnit Module
The JUnit module makes creating and running
JUnit tests easier and provides
a results window for quick overview of status of executed tests. When
generating test methods for existing classes, it generates reasonable and
compilable test code skeleton for each testable method. It also makes
navigation between source files and corresponding test files easy by providing
a navigation action with a shortcut.
Not all NetBeans projects support JUnit tests. Some projects such as
Java
Application projects provide full support for tests, some project types
(such as
Java Project with Existing Ant Script, aka "free-form
projects") may be setup for such support, and some project types do not
currently support JUnit testing at all (such as J2ME project
types – the support is under development).
Test classes are kept in separate source directories. (Update: this will not be
true for J2ME projects once support for them is added to the JUnit module).
Each
generated test class contains test methods for all accessible methods from
the tested class. These methods contain either a simple skeleton suitable for
comparing return values of tested methods with values expected by the tests
(by default), or these methods may be left empty,
the body of test method then has to be filled by the developer to
hold some reasonable test code. Generated test classes are compilable and by
default print names of tested methods.
More documentation
NetBeans 6.0
(released in December 2007)
supports both JUnit 3.x and JUnit 4. It is bundled with two versions of
the JUnit library – JUnit 3.8.2 and JUnit 4.1 (requires JDK 1.5+)
NetBeans 5.0
and
NetBeans 5.5
are bundled just with JUnit 3.8.1 and do not
support JUnit 4 tests. But it is still possible to run JUnit 4 tests with
NetBeans 5.x, with just a small change required in the main test class.
For more information about JUnit 3.8, JUnit 4, differencies between them
and supported JUnit-related features in NetBeans 5.x and 6.0, visit
this page.
To find more information about the JUnit framework and its
API,
visit web site www.junit.org.
To find help on using the NetBeans JUnit module, please read the NetBeans
IDE help.
There are several development documents available on the
docs page.
Want to comment or help?
We are open to your ideas. If you have any questions, suggestions or
improvements about this module, feel free to
send us an e-mail or subscribe to
one if the JUnit mailing lists (use the appropriate link on the left).