4 Mai 2017
Example of Modified condition/decision coverage (MC/DC - MCDC)
Assume we want to test the following code extract:
where A, B and C represent atomic boolean expressions (i.e. not divisible in other boolean sub-expressions).
In order to ensure Condition coverage criteria for this example, A, B and C should be evaluated at least one time "true" and one time "false" during tests, which would be the case with the 2 following tests:
In order to ensure Decision coverage criteria, the condition ( (A or B) and C ) should also be evaluated at least one time to "true" and one time to "false". Indeed, in our previous test cases:
and Decision coverage is also realized.
However, these two tests do not ensure a Modified condition/decision coverage which implies that each boolean variable should be evaluated one time to "true" and one time to "false", and this with affecting the decision's outcome. It means that from a test case to another, changing the value of only one atomic condition will also change the decision's outcome; although with only the two previous tests, it is impossible to know which condition influences the decision's evaluation...
In practice, for a decision with n atomic boolean conditions, we have to find at least n+1 tests in order to be able to ensure Modified condition/decision coverage. As there are 3 atomic boolean conditions (A, B et C) in our example, we can (for instance) choose the following set of tests:
Indeed, in this case:
Besides, Decision and Condition coverage criteria are still respected (each boolean variable and the decision's outcome itself take at least one time the "true" and "false" values). The Modified condition/decision coverage is then ensured.
More complex example
Assume we replace the condition:
A full Test Coverage would consist into building the following truth table and testing each combination:
On the other hand, to ensure Modified condition/decision coverage, we should test (for instance) only the 5 combinations here-before underlined in yellow.
Condition: a logical indivisible (atomic) expression. It is often called boolean variable, represented by a capital letter (A, B, C, etc.), can only be equal to "true" or "false", but can not be divided in other simpler "sub-conditions".
Decision : a logical expression which can be composed of several conditions separated by logical operators like "or", "and", "xor".
The Test Coverage Analyzer Testwell CTC++ can do measurements for all kinds of test coverage criteria (particularly for MC/DC and MCC) requested for "critical software development" in order to get certifications, such as DO-178B of the Federal Aviation Administration (FAA).