Changes between Version 8 and Version 9 of Developer/Coverage/Theory
- Timestamp:
- 09/10/09 22:20:52 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Developer/Coverage/Theory
v8 v9 10 10 The ultimate goal of Code Coverage Analysis is to ensure that a test suite adequately tests a particular body of code. In order to achieve this goal, several different coverage criteria may have to be examined. Let's consider the following criteria: 11 11 12 * ''' Object coverage''' - Has each line of generated assemblybeen executed?13 * ''' Statement coverage''' - Has each line of the source code been executed?14 * ''' Decision coverage''' (also known as Branch coverage) - Has each control structure (such as an if statement) evaluated both to true and false?15 * ''' Condition coverage''' - Has each boolean sub-expression evaluated both to true and false (this does not necessarily imply decision coverage)?16 * ''' Modified Condition/Decision Coverage|Modified Condition/Decision Coverage (MC/DC)''' - Has every condition in a decision taken on all possible outcomes at least once? Has each condition been shown to affect that decision outcome independently?12 * '''Statement Coverage''' - Has each line of the source code been executed? 13 * '''Decision Coverage''' (also known as Branch coverage) - Has each control structure (such as an if statement) evaluated both to true and false? 14 * '''Condition Coverage''' - Has each boolean sub-expression evaluated both to true and false (this does not necessarily imply decision coverage)? 15 * '''Modified Condition/Decision Coverage (MC/DC)''' - Has every condition in a decision taken on all possible outcomes at least once? Has each condition been shown to affect that decision outcome independently? 16 * '''Object Coverage''' - Has each line of generated assembly been executed? 17 17 18 [[Image(CoverageCategories.png)]]]] 19 20 Each of these criteria can be used independently to analyze the code in question. Application of any one criteria will likely improve the test suite to some degree. But each criteria has advantages and disadvantages. If we examine the criteria collectively, it can be seen that there are clear relationships between the different criteria as shown in the picture. If the test suite satisfies Statement Coverage, it will partially satisfy Decision Coverage and MC/DC. If the test suite satisfies Decision Coverage, it will completely satisfy Statement Coverage and partially satisfy MC/DC. There is also a complexity relationship where Statement Coverage is the least complex to satisfy and MC/DC is the most complex to satisfy. 21 22 <br style="clear: both" /> 23 24 If we consider the following example 18 In order to illustrate what is covered by each of the different criteria, consider the following simple example 25 19 26 20 {{{ … … 29 23 }}} 30 24 31 a ndits psuedo object code25 along with its psuedo object code 32 26 33 27 {{{ 34 28 cmp x, 0 35 29 branch if FALSE to do something 30 cmp y, 0 31 branch if TRUE around do something 32 do something instructions 36 33 }}} 37 = Object Coverage =38 39 40 TBD41 34 = Statement Coverage = 42 35 … … 51 44 52 45 This is also known as [http://en.wikipedia.org/wiki/Modified_Condition/Decision_Coverage Modified Condition/Decision Coverage]. 46 = Object Coverage = 47 48 49 TBD 50 = Criteria Relationships = 51 52 53 [[Image(CoverageCategories.png)]]]] 54 55 Each of these criteria can be used independently to analyze the code in question. Application of any one criteria will likely improve the test suite to some degree albeit at some cost. Examination of the criteria collectively, shows that there are clear relationships between the different criteria as shown in the picture. The completness of the test suite increases as it satifies first Statement Coverage and then Decision Coverage and finally MC/DC. If the test suite satisfies Statement Coverage, it will partially satisfy Decision Coverage and MC/DC. If the test suite satisfies Decision Coverage, it will completely satisfy Statement Coverage and partially satisfy MC/DC. There is also a complexity relationship where Statement Coverage is the least complex to satisfy and MC/DC is the most complex to satisfy. 56 57 <br style="clear: both" />