After

In this chapter you got past one of the more significant challenges: getting a first test to pass using JUnit in your IDE. Congrats! But life, and most “real” code, isn’t so simple. In the next chapter, you’ll tackle writing tests for a meatier example and learn quite a bit more about JUnit in the process.

Before moving on: we wrote one test against ScoreCollection. That might or might not be sufficient. Take a few moments and analyze ScoreCollection’s code. Ask yourself:

  • Do I need to write additional tests to feel confident that the code works?

  • Could I write tests that expose defects or limitations in the class?

In the next several chapters, we’ll explore how to best answer those questions for any code you’re testing.

Footnotes

[9]

Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.