Condition Coverage

Condition coverage includes decision coverage and additionally records if all atomic conditions inside decisions are evaluated to true and to false.

Example: The following function contains a decision consisting of four atomic conditions.

int multicondition(int a, int b, int c, int d){
  if ((a || b) && (c || d)){
    return 1;
  else {
    return 0;

It is tested with the input

multicondition(0, 0, 0, 1); // Test I
multicondition(0, 0, 1, 0); // Test II
multicondition(0, 0, 1, 1); // Test III
multicondition(0, 1, 0, 0); // Test IV
multicondition(0, 1, 0, 1); // Test V

The four conditions are covered in the following way by these test cases:

Condition a is obviously never true in the tests. Condition c is actually true in tests II and III, but the short-circuit evaluation prevents that this is measurable. Condition coverage is harder to be achieved for short-circuit evaluating languages.

For the code in line 2, ten measure points are taken into account for condition coverage: the true and false evaluation of the whole decision and for each of the four conditions.

Note: Condition coverage is reported
  • with ctcreport: option -measures ...,c,...,
  • with ctcpost: option -fc.
The instrumentation mode needs to be multicondition.