Understanding rules
The benefits of JUnit rules, especially when dealing with integration tests, can hardly be overrated. That's why, we start with a thorough explanation of how they work and how you can implement your own extensions. This will put you in a position to increase your daily work efficiency with the aid of custom rules.
What are JUnit rules?
"Pedantry and mastery are opposite attitudes toward rules." | ||
--George Pólya |
JUnit offers a particular test helper support that we've already encountered in the course of this book. Recollect the introduction of the ExpectedException
rule in Chapter 4, Testing Exceptional Flow, where you got a first impression of the possible applications. But what are rules exactly?
To answer this question, let's take a look at an example. Until now, we've concentrated our efforts on unit tests, which use DOCs as stand-in components to isolate SUTs from their dependencies. But at some point in time, you&apos...