Skip to content

Instantly share code, notes, and snippets.

@SujjithS
Created September 28, 2022 11:28
Show Gist options
  • Save SujjithS/d138ee23762434c33061c80c20e9c2ac to your computer and use it in GitHub Desktop.
Save SujjithS/d138ee23762434c33061c80c20e9c2ac to your computer and use it in GitHub Desktop.

#Coverage metrics supported by Squish Coco Several kinds of code coverage are possible with Squish Coco. The most common are:

##Statement Block Coverage With this metric, Squish Coco verifies that all statements are executed. For this it groups the statements of the program to blocks. Statements belong to the same block if they are always executed together. (Statement blocks roughly correspond to the “blocks” of most programming languages.) The coverage of a program is the number of executed statement blocks in it, divided by the total number of blocks. Decision (or Branch) Coverage Here Squish Coco verifies that all statements are executed and all decisions have all possible results. The coverage of a program is the number of executed statement blocks and decisions divided by the total number of statements and decisions – where each decision counts twice, once for the true case and one for the false case.

##Condition Coverage This is like decision coverage, except that the decisions are split into elementary subexpressions (or conditions) that are connected by “and” or “or” operators. The coverage of a program is the number of executed statement blocks and conditions divided by the total number of them. Here each condition counts twice, which may result in a large number of possible outcomes in a complex decision.

##Modified Condition/Decision Coverage (MC/DC) This is like condition coverage, but every condition in a decision must be tested independently to reach full coverage. For each condition there must be two executions that differ only in the results of the condition, while the other conditions have the same result. In addition, it needs to be shown that each condition independently affects the decision. The coverage of a program is the number of executed statement blocks and of conditions that were tested independently divided by the number of statement blocks and conditions in the program.

##Multiple Condition Coverage In this coverage metric, all statements must be executed and all combinations of truth values in each decision must occur at least once to reach full coverage. The coverage of a program is the number of executed statement blocks and condition combinations divided by their total number in the program. Other, simpler coverage metrics are also supported.

##Function coverage With this metric, Squish Coco counts which functions were called and how often. “Functions” includes also the member functions of objects, as always with Squish Coco. The coverage of a program is then the number of functions that were called at least once, divided by the total number of functions. Relevance for safety standards: IEC 61508 highly recommends 100% structural test coverage of entry points (i.e. functions) for SIL 1, 2, 3 and 4.

##Line coverage the number of executed code lines is counted and how often each one of them was executed. Only lines that contain executable statements are instrumented, not those with pure declarations. The coverage of a program is then the number of executed lines divided by the number of instrumented lines. Line coverage is an unstable coverage measurement since it depends strongly on the way the code is formatted (see Chapter 5.6). We do not recommend line coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment