O'Reilly logo

Testing with JUnit by Frank Appel

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

Chapter 6. Reducing Boilerplate with JUnit Rules

We already explained how to minimize clutter and redundancy in test cases by extracting coherent utility code into separate test helpers, as seen in Chapter 3, Developing Independently Testable Units. In this chapter, you'll learn how to enhance this strategy by means of JUnit rules. You'll be given an introduction to the approach's mechanics and potential. To deepen this knowledge, we'll continue by writing and varying a sample extension. Then, we'll examine advanced features of rules-related functionality and conclude with the inspection of useful third-party vendor offerings. In short, this will make us capable of the following:

  • Understanding rules
  • Working with advanced concepts
  • Employing custom ...

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