Statement & Decision Coverage

I though sharing the difference between statement coverage in decision coverage.

Statement : “an entity in programming language which is typically the smallest indivisible unit of execution”

Statement testing is a white box test design technique.

Statement coverage checks the “True” condition only while the decision or branch coverage covers both the “True & False” conditions

Decision coverage is also a white box technique in which the test cases are designed to execute decision outcomes.

In sequential code, for example

ad = i+t; x= y*z;

In this case, there is no decision, so there is need of only 1 test case.

IF

If (Cond) { ad = i +t; } Here we need 1 test case to cover all test case.

IF ELSE

IF(Cond1) {ad = i + t;} else {a = b*c;}

To cover all statements we need 2 test cases. and to cover all decisions we need 2 test cases.

Swithc(True) { case 0: a =b+c; break; case2: d=e+f;break; case3: d=e+f;break; case4: d=e+f;break; }

here we need 4 test cases to cover all the statements and to cover all decisions. Statement-Decision-Branch-coverage contains some excercises for you to practise.

Leave a Comment

Your email address will not be published. Required fields are marked *