JUnit
JUnit is a simple framework to write repeatable tests. It is an instance of
the xUnit architecture for unit testing frameworks.
Getting Started
To get started with unit testing and
JUnit read the Java Report article: Test Infected -
Programmers Love Writing Tests.
This article demonstrates the
development process with JUnit in the context of multiple currency arithmetic.
The corresponding source code is in junit\samples\money.
You find additional samples in the junit.samples package:
- SimpleTest.java - some simple test cases
- VectorTest.java - test cases for java.util.Vector
Which TestRunner to use?
JUnit comes with different TestRunners:
- a textual TestRunner - it is the fastest to launch and can be used when
you don't need a red green success indication.
- graphical TestRunners - they show a simple graphical dialog to enter the
test and provide some graphical progress indication. A TestRunner can be
configured to be either loading or non-loading. In the loading
configuration the TestRunner reloads your class from the class path for each
run. As a consequence you don't have to restart the TestRunner after you have
changed your code. In the non-loading configuration you have to restart the
TestRunner after each run. The TestRunner configuration can be either set on
the command line with the -noloading switch or in the junit.properties file
located in the "user.home" by adding an entry loading=false.
Notice:
don't use the loading behaviour when you are testing code that exercise JNI
calls.
The loading behaviour can be further configured with the
excluded.properties file. In this file you can configure the list of package
paths that should be excluded from loading. The loading of these packages is
delegated to the system class loader. They will be shared across test runs.
The excluded.properties file is located at in the junit.jar file and can be
overridden by adding an excluded.properties file infront of the junit.jar
file.
Documentation
README
JUnit
Cookbook
A cookbook for implementing tests with
JUnit.
Test Infected
- Programmers Love Writing Tests
An article
demonstrating the development process with JUnit.
JUnit - A
cooks tour
Frequently asked
questions
Some frequently asked questions about
using JUnit.
JUnit Related Projects/Sites
- junit.org - a site for software
developers using JUnit. It provides instructions for how to integrate JUnit
with development tools like JBuilder and VisualAge/Java. As well as articles
about and extensions to JUnit.
- XProgramming.com -
various implementations of the xUnit testing framework architecture.
Mailing Lists
There are three junit mailing lists:
Get Involved
JUnit celebrates programmers testing their own software. As a result
bugs, patches, and feature requests which include JUnit TestCases have a
better
chance of being addressed than those without. JUnit is forged on
Sourceforge please use the tools provided for your submissions.
hosted by