Test Coverage Should Be About State Space Not LOC

Posted 2 years ago | Originally written on 31 Oct 2022

I've stated previously that test coverage by measuring lines of code (LOC) is not a reliable measure of code quality. The gold standard should be coverage of the state space. Most applications can completely be defined by a finite state machine: given a range of input parameters, the application can exist in only a subset of possible states. Therefore, the cardinality of inputs combined with the number of distinct categories per input gives the size of the space. We also have to consider that even a single input instance has within it a state space associated with that input. The full ensemble of such states should be probed by the test suite. Therefore, knowing the relationship between inputs and final states is a powerful way to exhaustively cover all states hence achieve true 100% coverage.

Remind me to write an example...