Skip to main content

Multiple Condition Coverage (MCC)

MCC Metric Definition

In the MCC 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.

Platforms-Compilers-750x750

Example

A C/C++ function with a decision based on a composed set of conditions nicely shows the difference between MCC and plain Condition Coverage:

bool isValidPosition(int x, int y, int z)
{
    if ((x > 10 || y > 20) && z > 0)
        return true;
    else
        return false;
}

For 100% MCC all combinations of truth values for the tree boolean expressions x > 10, y > 20 and z > 0 need to be exercised. One might expect 23 = 8 tests to be needed. Languages like C, C++, C# and JavaScript perform a so called short-circuit evaluation: If x > 10 evaluates to TRUE the expression y > 20 won’t be evaluated anymore. Likewise, if neither x > 10 nor y > 20 is TRUE z > 0 won’t be valuated anymore as it cannot change the decision anymore.

 

 

As a result the number of possible combinations and number of needed tests for 100% Multiple Condition Coverage is reduced to these five:

x > 10 y > 20 z > 0
FALSE TRUE TRUE
TRUE   TRUE
FALSE TRUE FALSE
TRUE   FALSE
FALSE FALSE  

 

Drawbacks

The number of possible combinations can ‘explode’ in light of big numbers of conditions. To mitigate this problem the Modified Condition/Decision Coverage metric was created.

Alternate Name

Multiple Condition Coverage is also known as Multicondition Coverage and Condition Combination Coverage.

Relation to Other Metrics

100% Multiple Condition Coverage implies 100% Modified Condition/Decision Coverage, 100% Condition Coverage and so forth.

Unlike Condition Coverage
a) all possible combinations and 
b) the decision outcomes
are considered.


Relevance of MCC for Safety Standard EN 50128

EN 50128 recommends MCC (or Modified Condition/Decision Coverage) for SIL 1 and 2. For SIL 3 and 4 this level is even highly recommended.

How Can We Help You?

We're here to support you! Whether you have questions about our advanced code coverage analysis and tool qualification, want to try Coco, or are interested in exploring our entire Qt Quality Assurance product portfolio, please don't hesitate to reach out.