Decision coverage and branch coverage are closely-related forms of structural coverage analysis. Decision coverage is referenced by DO-178B/DO-178C whereas branch coverage is referenced by ISO 26262. Branch coverage requires every exit from a conditional source code statement to be executed. Thus, for an if
statement, branch coverage requires the then
part and the else
part to be executed (if there is no else
part, the if statement should still execute the decision as true and false). For decision coverage, the DO-178B/DO-178C definition of decision covers conditional statements, in the same way as branch coverage, but it also includes assignments of Boolean variables, for example:
a := b or (c and d); (Ada) a = b || (c && d); (C/C++)
In this case, decision coverage would require tests for the above assignment making a
both true and false.
Moreover, given the same source code and tests to exercise it, the percentage of coverage reported may be different between branch and decision coverage. For example, if 3 out of the 4 branches of a switch
statement are executed, the branch coverage would be reported as 75%
, but for decision coverage, a decision is considered covered only if all its branches are covered, so the coverage of the switch statement would be reported as 0%
.
Find out more about structural coverage in our white paper.