Approaches

  • Unit testing
  • Randomised testing
  • Test cases from specifications
    • Equivalence partitioning
    • Boundary values
  • Test cases from implementations
    • Execution paths
    • Symbolic execution (?)
    • Specifying execution paths
  • Automation

We base the discussion of testing and test case generation on unit testing. The motivation for this is that all test cases considered can be executed using existing unit test frameworks. We review some basics about unit testing without attempting to be exhaustive. Instead, we focus on how to come up with test cases that increase our confidence that a function under consideration is correct. We discuss three different approaches to producing test cases

  • Randomised testing chooses randomly generated input values.

  • Testing from specifications derives values from contracts ignoring implementations

  • Testing from implementations derives values from implementations using contracts

Testing from specifications is also called black-box testing and testing from implementations white-box testing. Our terminology is close to our methodology based on contracts –the specifications– and function bodies –the implementations.