Remembering Boundary Conditions with CORRECT

The CORRECT acronym gives you a way to remember potential boundary conditions. For each of these items, consider whether or not similar conditions can exist in the method that you want to test, and what might happen if these conditions are violated:

  • 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)?

  • Cardinality—Are there exactly enough values?

  • Time (absolute and relative)—Is ...

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.