O'Reilly logo

Effective Unit Testing: A guide for Java Developers by Lasse Koskela

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix B. Extending JUnit

Before JUnit reached its venerable 4.0 version, the API was based on your test class inheriting from junit.framework.TestCase, and extending JUnit was done by overriding parts of the inherited behavior. With the annotation-based approach adopted by the latest version of JUnit, extensions have a new shape and are hooked up through—you guessed it—annotations.

The main concepts relevant for extending the built-in JUnit behavior are runners and rules. Though we’re not going to delve too deeply into writing custom extensions, you should be aware of what kind of extensions come built-in with JUnit and where to start when you do want to write a custom extension.

We’ll begin with a brief look at how the runners work. Implementing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required