Condition Testing and Coverage

Profile picture for user devraj

If a decision is based on several conditions connected by logical operators, then the complexity of the condition should be considered in the test.

A computer program consist of statements, such as IF and WHILE statements, that contain conditions, which are combinations of Boolean and relational expressions. A testing approach, referred to as condition testing, is to test a program by focusing on testing the conditions in this program.

The goal of condition testing is to cause each atomic partial condition in the test to adopt both a true and a false value. An automic partial condition is a condition that has no logical operators such as AND, OR, and Not but at the most includes relation symbols such as > and =.

An example of combined condition is x > 2 OR y < 4. Here 2 conditions are connected by the OR. The goal of condition testing is that each partial condition is evaluated once, resulting in each of the logical values.= 5 holds true because either of one should be true for OR condition. When value are x = 2 and y = 4 both conditions will return false.

Multiple condition testing requires that all true-false combinations of the atomic partial conditions be exercised at least once. For x > 2 OR y < 4 conditions 4 combinations are possible. 

X = 3 (T), y = 3 (T), Result True
X = 3 (T), y = 5 (F), Result True
X = 2 (F), Y = 3 (T), Result True
X = 2 (F), Y = 4 (F), Result False

Thus multiple conditions testing meets the criteria of statement and branch coverage. 

A problem results from the fact that test data cannot always generate all combinations. Example x >= 2 AND x < 4 because there is no value of x where both conditions will be false.

X = 3, x>=2 (T), x<4(T), Result True
X = 7, x>=2 (T), x<4(F), Result False
X = 1, x>=2 (F), x<4(T), Result False
x = ?, x>=2 (F), x<4(F), False combination is not possible because 
x can not be smaller than 2 and greater than 4 at same time

Condition determination testing or minimal multiple condition testing eliminates the problems above. Test case in which the result does not depend on a change of an atomic partial condition need not to be designed. Consider example: x > 2 OR y < 4. There were 4 combinations:

Case 1: X = 3 (T), y = 3 (T), Result True
Case 2: X = 3 (T), y = 5 (F), Result True
Case 3: X = 2 (F), Y = 3 (T), Result True
Case 4: X = 2 (F), Y = 4 (F), Result False

In above example in Case 1 any of partial condition result calculated wrong the result will still remain true. So condition 1 can be left our. In Case 2 if first value wrongly calculated both false will result in true so failure will become visible. Similar is the case with Case 3 2nd partial condition. Similarly with case 4 fault will occur if any of logical value change.

For designing the test cases, it must be considered which input data leads to which result of the decision or partial conditions and which parts of the program will be executed after the decision. If complex decisions are present in the source code, they must be tested intensively to detect possible failure.

A disadvantage of condition testing is that it checks Boolean expression only inside a statement. Another problem occurs in connection with measuring the coverage of partial conditions.