0% found this document useful (0 votes)
31 views

How To Calculate Statement

To calculate statement coverage, test cases are executed to traverse every node in the flow diagram at least once. Branch coverage requires test cases such that each condition takes on true and false outcomes at least once, validating all branches. Steps include drawing a flow diagram with nodes for code entries, exits, decisions and statements, and edges for branching and non-branching links. For the example given, statement coverage is achieved with one path, while two paths are needed for full branch coverage and four paths for full path coverage.

Uploaded by

Rahul Kumar Raja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

How To Calculate Statement

To calculate statement coverage, test cases are executed to traverse every node in the flow diagram at least once. Branch coverage requires test cases such that each condition takes on true and false outcomes at least once, validating all branches. Steps include drawing a flow diagram with nodes for code entries, exits, decisions and statements, and edges for branching and non-branching links. For the example given, statement coverage is achieved with one path, while two paths are needed for full branch coverage and four paths for full path coverage.

Uploaded by

Rahul Kumar Raja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

How to calculate Statement, Branch/Decision Coverage

Statement Coverage: (Find shortest path such that all nodes are covered
at-least once)
o In this, the test case is executed in such a way that every node is
traversed at-least once.
See the below example and understand
Refer diagram.
Branch/Decision Coverage: (Find shortest path such that all the Edges
are covered at-least once)
Test coverage criteria requires enough test cases such that each condition in
a decision takes on all possible outcomes at least once, and each point of
entry to a program or subroutine is invoked at least once. That is, every
branch (decision) taken each way,true and false. It helps in validating all the
branches in the code making sure that no branch leads to abnormal behavior
of the application.

Steps hai kaise solve kare problems ko:-Draw the flow in the following way Nodes(Boxes) represent entries, exits, decisions and each statement of
code.
Edges (Links) represent non-branching and branching links between
nodes.
Example:
Read P
Read Q
IF P+Q > 100 THEN
Print Large
ENDIF
If P > 50 THEN
Print P Large
ENDIF
Calculate statement coverage, branch coverage

Statement Coverage (SC):


To calculate Statement Coverage, find out the shortest number of paths following
which all the nodes will be covered. Here by traversing through path 1A-2C-3D-E4G-5H all the nodes are covered. So by traveling through only one path all the
nodes 12345 are covered, so the Statement coverage in this case is 1.

Branch Coverage (BC):


To calculate Branch Coverage, find out the minimum number of paths
which will ensure covering of all the edges. In this case there is no single
path which will ensure coverage of all the edges at one go. By following
paths 1A-2C-3D-E-4G-5H, maximum numbers ofedges (A, C, D, E, G
and H) are covered but edges B and F are left. To covers these edges we
can follow 1A-2B-E-4F. By the combining the above two paths we can
ensure of traveling through all the paths. Hence Branch Coverage is 2.
The aim is to cover all possible true/false decisions
PathCoverage(PC):
Path Coverage ensures covering of all the paths from start to end.
All possible paths are1A-2B-E-4F
1A-2B-E-4G-5H
1A-2C-3D-E-4G-5H
1A-2C-3D-E-4F
So path coverage is 4.
Thus for the above example SC=1, BC=2 and PC=4.
Memorize

100% Path coverage will imply 100% Statement coverage.


100% Branch/Decision coverage will imply 100% Statement coverage.
100% Path coverage will imply 100% Branch/Decision coverage.
Branch coverage and Decision coverage are same.

You might also like