Monday, May 23, 2011

Statement Coverage, Branch / Decision coverage and Path coverage

Statement Coverage: Check if each statement in the code has been executed at least once
Branch / Decision coverage: Check if each possible branch from a decision point has been executed at least once
Path coverage: Check if every possible path is executed at least once.

Example:
READ P, Q
IF P+Q > 100 THEN
PRINT 'LARGE'
END IF
IF P>50
PRINT 'P Is Greater'
END IF

Draw flow diagram for this code:

Statement coverage: We need 1 test case to cover all the statements in the code

Branch/Decision coverage: We need 2 test case to cover all the branches in the code

Path coverage: We need 4 test case to cover all the paths in the code

6 comments: