Coverage types in white box testing

White box testing generally focus on the structure of the code and find bugs related to the structure of the code like some statement not executed, some condition is never met etc. It is very useful in detecting dead code and unreachable code along with bug which are initiated by execution of particular statement or satisfaction of particular condition.
For test adequacy criteria for white box testing we put some limit on the code coverage like we can state that white box testing is completed when 90% of the statements in the code have been executed. Coverage can be statement coverage, decision coverage condition coverage, or both condition decision coverage or modified condition decision coverage. These coverage criteria are ordered in the increasing power of revealing defects and the no of test cases required achieving them.

Statement coverage
: If the test adequacy criteria statement is like all (100%) statements in the code shall be executed before testing is completed then tester has to design test suite in such a fashion that every statement in the code is executed at least once.
This type of coverage can reveal defects in improper assignments or computation but it cannot reveal defect that is originated from a missing statement.
For example we have a code
If (age<65 data-blogger-escaped-and="" data-blogger-escaped-married="=TRUE)
For 100% statement coverage of this code we need two test cases one for if part and other for else part.
TestId1 age=30 and married=true statement 1, statement2
TestId2 age=70 and married=true statement3, statement4

Decision coverage
: This coverage makes sure that each and every branch in the code has been executed. It execute all decision statement like if then else, for loop, while loop and ensure all the outcome of the statement have been executed. It is considered stronger coverage then statement coverage because decision coverage will automatically executes all statements and in addition it also verifies all decisions/branches.
Above mentioned example also satisfies the decision coverage criteria, where TestId1 covers if part and TestId2 covers the else part.

Condition coverage: Most of the time decision statements consist of more than one condition. For decision coverage we only require that the path shall be executed without bothering which condition has been satisfied for that. This can be dangerous when short circuiting occurs.
For example in the above mentioned code, we had 100% branch coverage but it has not shown the effect of the variable ‘married==false’. To cover all the condition we have to rewrite the TestID1 as age=30 and married=false. Now in the decision we have two conditions taking all possible values.
TestId1 age=30 and married=false Decision outcome: false
TestId2 age=70 and married=true Decision outcome: false

Condition/decision coverage: In above example, we can see that although each condition has taken all possible outcomes but the decision has taken only one value (not all possible value). To address this problem, we have another criterion that is condition/decision coverage which mandate that all conditions take there possible outcomes as well as all decision outcomes are also taken or all branches are also executed. Taking the above example, we have to write another test case for this.

TestId3 age=30 and married=true Decision outcome: true
By looking carefully we can remove this extra test case by modifying above test cases as

TestId1 age=30 and married=true Decision outcome: true
TestId2 age=70 and married=false Decision outcome: false
These two test cases now will give 100% condition coverage and 100% decision coverage.

Modified condition/ decision coverage
: As we can see from above test case, all combinations for all the conditions in a decision are not required in any of the above criterion. Modified condition/ decision coverage mandates that all the possible combinations of the conditions in the decision shall be executed for each outcome of the decision.
For example test cases for the above mentioned code will be
TestId1 age=30 and married=true Decision outcome: true
TestId2 age=70 and married=false Decision outcome: false
TestId3 age=70 and married=true Decision outcome: false
TestId4 age=30 and married= false Decision outcome: false

To identify and write test cases for such criteria we use binary table and assign each condition true/false value and based on that find out the decision value.
100% MCDC coverage is mandatory for the any software which is safety critical of level A according to DO-178B

These are the various coverage criteria in white box testing.