How Ya Feelin’ Now?
This book provides two starter examples for a few reasons. The first example (Chapter 1, Building Your First JUnit Test) demonstrates the basics of how to use JUnit and minimizes the distraction of involved logic. That’s not good enough for Pat, who would claim, “See? Unit testing is only good on toy examples.”
Hence the second example in this chapter, which contains a reasonably complex set of logic. We hope it doesn’t dissuade you from wanting to unit-test your code, but this is reality: methods like matches() embody a surprising number of branches and cases that each suggest the need for yet another test.
So far, we’ve covered only two paths through the matches() method. The smaller effort required to write the second ...
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