Statement Code Coverage is the number of the code statements executed over the total number of code statements for the executable under test. Safety critical systems looking to be certified for DO-178C Level C require every line to be executed during the testing phase. Full coverage testing is useful in finding untested functionality and/or dead code.
To properly test the code shown below for statement coverage, at least two tests are required to cover both conditions. The coverage results will show the final return statement can never be executed. The code needs to be fixed.
int main (int argc, char **argv) { if (argc > 1) { printf(“Thanks for the command line arguments!\n”); return 1; } else { printf(“I need command line arguments!\n”); return –1; } return 0; } |
Full statement coverage is a good starting point for the verification process of a safety-critical system, but does not imply the code has been tested to a satisfactory level. In more complex systems, Decision Coverage testing is needed to make sure that all possible outcomes of a program have been reached. Finally, high-level and low-level requirements testing will help verify that each statement is actually doing what it is intended to be doing.