The differences between JUnit 3 and JUnit 4

cody picture cody · Jul 13, 2011 · Viewed 16k times · Source

Could someone describe in a few words what the main differences between JUnit 3 and 4 are?

Answer

Paul Sanwald picture Paul Sanwald · Jul 13, 2011
  1. Java 5 annotations for setup and teardown (@before and @after) instead of setUp() and tearDown().

  2. don't need to extend TestCase anymore.

  3. @Test annotation replaces testSomeMethod() naming convention.

  4. static imports for asserts.

  5. Junit theories, which allow you to separate data sets from the test itself.