Right-[B]ICEP: Boundary Conditions

An obvious happy path through the code might not hit any boundary conditions in the code, which are 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:

Boundary conditions we might want to think about include:

  • Bogus or inconsistent input values, like 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 a numeric overflow.
  • Empty or missing values, such as 0, 0.0, "", or null.
  • Values far in excess of reasonable expectations, such as a person with an age of 150 years.
  • Duplicates in lists that shouldn’t have duplicates, such as a roster of students in a classroom.
  • Ordered lists that are not ordered and vice versa.
  • Things that happen in unexpected chronological order, such as an HTTP server that returns an OPTIONS response after a POST, instead of before.

The ScoreCollection code given below seems innocuous enough:

Get hands-on with 1200+ tech skills courses.