Appendix A. Differences between JUnit 3 and JUnit 4

This appendix covers

  • Changes between version 3.x and 4.x of JUnit
  • API changes
  • New features in JUnit 4.x

As you’ve probably seen, the new 4.x version of JUnit is a completely new framework. It’s more of a totally new project than a bug-fixing improvement of the old one. But it still deals with unit testing your Java code. That said, we will try to define all the differences between the latest version of JUnit and the 3.x version.

A.1. Global changes

This section discusses the changes in the requirements for using JUnit.

A.1.1. JDK required

JUnit 4 uses a lot from Java 5 annotations, generics, and static import features. Although the JUnit 3.x version can work with JDK 1.2+, this usage ...

Get JUnit in Action, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.