JUnit 4.0 released – Annotations based TestCase definitions


Last week, release 4.0 of JUnit was published. You may have seen some of the announcements. The JUnit homepage (http://www.junit.org/index.htm)does not reflect this fact at the time of writing, but the 4.0 Jar is available for download at SourceForge (http://sourceforge.net/project/showfiles.php?group_id=15278). I found a very good article for getting started with this JUnit release: JUnit 4.0 in 10 minutes by Gunjan Doshi (Instrumental Services Inc. ). It very conscisely explains what is new about this release and how it will influence the way we use JUnit.

Some important conclusions:

  • JUnit 4.0 requires JDK 5.0 as it uses annotations to specify which classes are TestCases (no extension of TestCase is required) and which methods are in fact UnitTests (the method name does not need to begin with test)
  • This release makes writing tests a little easier and little more flexible (no more mandatory TestCase superclass for example)
  • Old (pre 4.0) JUnit Tests can still be run with the 4.0 Runner
  • The current generation of IDEs does not know about the JUnit 4.0 style of annotating classes, hence we will need an Adapter until they are up to speed (the adapter is part of the JUnit 4.0 release)

About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director for Fusion Middleware. Consultant, trainer and instructor on diverse areas including Oracle Database (SQL & PLSQL), Service Oriented Architecture, BPM, ADF, Java in various shapes and forms and many other things. Author of the Oracle Press book: Oracle SOA Suite 11g Handbook. Frequent presenter on conferences such as JavaOne, Oracle OpenWorld, ODTUG Kaleidoscope, Devoxx and OBUG. Presenter for Oracle University Celebrity specials.

Comments are closed.