Boundary testing and structural testing

The most challenging part of specification-based testing is identifying boundaries. They are tricky to find, given the way we write specifications. Luckily, they are much easier to find in source code, given how precise code has to be.

The idea of identifying and testing on and off points fits nicely in structural testing. For example, we can analyze the if statements in the leftPad program:

  • if (pads <= 0)—The on point is 0 and evaluates the expression to true. The off point is the nearest point to the on point that makes the expression evaluate to false. In this case, given that pads is an integer, the nearest point is 1.
  • if (pads == padLen)—The on point is padLen. Given the equality and that padLen is an integer, we have two off points: one that happens when pads == padLen - 1 and another that happens when pads = padLen + 1.
  • if (pads < padLen)—The on point is again padLen. The on point evaluates the expression to false. The off point is, therefore, pads == padLen - 1.

As a tester, you may want to use this information to see whether you can augment your test suite.

We discussed the loop boundary criterion earlier, which helps us try different possible boundaries. If a loop has a less conventional, more complicated expression, consider applying on and off analysis there as well.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *