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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access