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

Snehakesarwani Loop Call Path Coverage

Uploaded by

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

Snehakesarwani Loop Call Path Coverage

Uploaded by

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

Name -Sneha Dilip Kesarwani

Seat No. : 31010922037

Subject :- Software Testing


Practical no:

Title: White Box Testing: Loop Coverage, Call coverage and Path Coverage.

Problem Statement:
0 Euclid(int m, int n){
1 int r;
2 if (n > m){
3 r = m;
4 m = n;
5 n = r;
6 }
7 r = m % n;
8 while( r! = 0){
9 m = n;
10 n = r;
11 r = m % n;
12 }
13 return n;
14 }

Step 1: Number the line of code

Step 2: Flowchart
Step 3: Calculate the cyclomatic complexity
V(G) : Cyclomatic Complexity, E : No of Edges, N: No of Nodes, P : No of connected areas/ no
of methods V(G) = E – N + 2P
= 16 – 15 + 2
=3

V(G) = No of predicates/Conditions + 1

Step 4: Basis Test Path


Test Path B1: 0 1 2 7 8 13 14
2: n>m ==> FALSE
8: r!=0 ==> FALSE

Test Path B2: 0 1 2 3 4 5 6 7 8 13 14


2: n>m ==> TRUE
8: r!=0 ==> FALSE

Test Path B3: 0 1 2 3 4 5 6 7 8 9 10 11 12 8 13 14


2: n>m ==> TRUE
8: r!=0 ==> TRUE
8: r!=0 ==> FALSE

Statement Coverage = Total no of statement executed/ Total number of statement


Statement Coverage for B1 =7/15
Statement Coverage for B2 =11/15
Statement Coverage for B3 = 15/15
Overall Statement Coverage =

Decision Coverage = no of decision outcomes executed/ total number of decision outcomes


No of Decision outcome = 4 node 2: n>m : True(B2, B3) / False (B1) ⇒ 2 node 8: r!=0 :
True(B3) / False
(B1,B2,B3) ⇒ 2

Total number of decision outcome = 2𝑛𝑜 𝑜𝑓 𝑐𝑜𝑛𝑑𝑖𝑡𝑖𝑜𝑛𝑠

=4
Decision Coverage for over all Code = 4/4 * 100 = 100%

100% decision coverage guarantees 100% statement coverage, but not the other way around!

Conclusion:
The control flow graph is drawn and the cyclomatic complexity is determined to be 3. Three
basis paths are to be tested.
Practical no:

Title: White Box Testing: Loop Coverage, Call coverage and Path Coverage.

Problem Statement:
Step 1: Number the line of code

Step 2: Flowchart
Step 3: Calculate the cyclomatic complexity

V(G) = E – N + 2=4

Step 4: Basis Test Path


Test Path B1: 1 2 3 4 5 20
6:if(MaxCount > Iterations) ==> FALSE
8: while (count < Iterations) ==> FALSE
12: if ( < Iterations) ==> FALSE

Test Path B2: 1 2 3 4 5 6 7 19 20


6:if(MaxCount > Iterations) ==> TRUE
8: while (count < Iterations) ==> FALSE
12: if ( < Iterations) ==> FALSE
Test Path B3 : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 6:if(MaxCount > Iterations)
==> TRUE
8: while (count < Iterations) ==> TRUE
12: if ( < Iterations) ==> TRUE

Statement Coverage = Total no of statement executed/ Total number of statement


Statement Coverage for B1 =6/20
Statement Coverage for B2 =9/20
Statement Coverage for B3 = 20/20

Decision Coverage = no of decision outcomes executed/ total number of decision outcomes No


of Decision outcome = 4

6:if(MaxCount > Iterations) => true , false =2


8: while (count < Iterations) => true , false = 2
12: if ( < Iterations) => true , false = 2

Total number of decision outcome = 2𝑛𝑜 𝑜𝑓 𝑐𝑜𝑛𝑑𝑖𝑡𝑖𝑜𝑛𝑠

= 23 = 8
Decision Coverage for over all Code = 6/8 * 100 = 75%

100% decision coverage guarantees 100% statement coverage, but not the other way around!

Conclusion:
The control flow graph is drawn and the cyclomatic complexity is determined to be __4___.
_Three___ basis paths are to be tested.

You might also like