Chapter 7Boundary Conditions: The CORRECT Way

Your unit tests can help you prevent shipping some of the defects that often involve boundary conditions—the edges around the happy-path cases where things often go wrong.

In the previous chapter, you got a whiff of the CORRECT acronym, which can help you think about the boundary conditions to consider for your unit tests:

  • Conformance—Does the value conform to an expected format?

  • Ordering—Is the set of values ordered or unordered as appropriate?

  • Range—Is the value within reasonable minimum and maximum values?

  • Reference—Does the code reference anything external that isn’t under direct control of the code itself?

  • Existence—Does the value exist (is it non-null, nonzero, present in a set, and so on)? ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.