If you’ve managed to get to 100% MC/DC, does that mean you’ve tested 100% of your requirements?
Remember that 100% MC/DC means that all of the Boolean decisions have been exercised and that entry and exit of each function has been covered. Requirements will typically govern input-output relationships for the whole function. For example, consider the function:
int perc_mix( int perc, int p0, int p100 ) { int result; if( perc < 0 ) { result = p0; } else if( perc > 100 ) { result = p100; } else { result = ((p0 * perc) / 100) + ((p100 * ( 100-perc )) / 100); } return result; }
And its requirements:
1: at perc
=100 or over, return p100
2: at perc
=0 or below, return p0
3: at perc
between 0
and 100
, return a linear weighted mean of p0
and p100
, with the weight p0=1
, p100=0
at perc=0
and p0=0
, p100=1
at perc=100
.
A test suite of perc=-50
, perc=0
, perc=100
, perc=150
achieves full MC/DC but does nothing to exercise requirement 3. (Hopefully the tests have been constructed with differing values of p0
and p100
, so that the error in the else-branch of the implementation can be found.) To demonstrate that you’ve tested 100% of your requirements, you need to show:
- That you have a test for 100% of your requirements;
- That 100% of your tests actually test a requirement;
- That every test passes.
Notice that these can be achieved by review – MC/DC is not playing a part here.
So what is MC/DC doing? Once you’ve met the above conditions and you also achieve 100% MC/DC, you will know that your tests have exercised all of the decisions and conditions in your application.