Before you start
The introduction of Java 5 annotations brought dramatic changes to JUnit, transforming it from the testing framework developers had grown to know and love into something more streamlined but less familiar. In this tutorial, I discuss the most important changes to JUnit 4 and introduce the exciting new features you've probably heard about but may not yet be using.
This tutorial guides you step-by-step through the fundamental concepts of JUnit 4, with emphasis on the new Java 5 annotations. At the conclusion of this one-hour tutorial, you will understand the major changes to JUnit 4, as well as being familiar with features such as exception testing, parametric testing, and the new flexible fixture model. You will know how to declare a test, how to use annotations (rather than suites) to logically group tests prior to running them, and how to run tests in Eclipse 3.2 or Ant, as well as from the command line.
To get the most from this tutorial, you should be familiar with Java development in general. This tutorial also assumes that you understand the value of developer testing and are familiar with basic pattern matching. To follow the section on running JUnit 4 tests, you should be able to work with Eclipse 3.2 as an IDE and with Ant 1.6 or greater. You need not be familiar with previous versions of JUnit to follow the tutorial.
To follow along and try out the code for this tutorial, you need a working installation of Sun's JDK 1.5.0_09 (or later) or the IBM developer kit for Java technology 1.5.0 SR3. For the sections on running JUnit 4 in Eclipse, you need a working installation of Eclipse 3.2 or later. For the section on Ant, you need version 1.6 or greater.
The recommended system configuration for this tutorial is as follows:
- A system supporting either the Sun JDK 1.5.0_09 (or later) or the IBM developer kit for Java technology 1.5.0 SR3 with at least 500MB of main memory
- At least 20MB of disk space to install the software components and examples covered
The instructions in the tutorial are based on a Microsoft Windows operating system. All the tools covered in the tutorial also work on Linux and UNIX systems.


