Right-[B]ICEP: Boundary Conditions

An obvious happy path through the code might not hit any boundary conditions in the code—scenarios that involve the edges of the input domain. Many of the defects you’ll code in your career will involve these corner cases, so you’ll want to cover them with tests.

Boundary conditions you might want to think about include:

  • Bogus or inconsistent input values, such as a filename of "!*W:X\&Gi/w$>$g/h#WQ@.

  • Badly formatted data, such as an email address missing a top-level domain (fred@foobar.).

  • Computations that can result in numeric overflow.

  • Empty or missing values, such as 0, 0.0, "", or null.

  • Values far in excess of reasonable expectations, such as a person’s age of 150 years.

  • Duplicates in lists that shouldn’t ...

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.