• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
White Box Testing Tutorial – 3: Estimation of Complexity Measure V(G)For a program evaluating Examination of StudentsIn this tutorial, the program inputs the marks of five subject of 
 
40 students and outputs average marksand the pass / fail message.Objective of the Tutorial:
To draw a Flow Graph, find its Cyclomatic Complexity, V(G) and the independentpaths for a piece of code given below.
A brief Introduction to Basis Path Testing & measurement of Complexity Measure V(G):
Basis path testing helps a tester to compute logical complexity measure, V(G), of the code. This value of V(G), defines the maximum number of test cases to be designed by identifying basis set of execution pathsto ensure that all statements are executed at least once.
Steps to compute the complexity measure, V(G) are as under Step – 1:
Construct the flow graph from the source code or flow charts.
(Refer Tutorial on “ What is a Flow Graph & Understand its Notations”)Step – 2:
Identify independent paths.
Step – 3:
Calculate Cyclomatic Complexity, V(G).
Step – 4:
Design the test cases. 
Starting point for the Tutorial: Is the Code: 
# include <stdio . h>(1) main ( ) {(2) int num student, marks, subject total ;(3) float average ;(4) num_student = 1;(5) while (num_student < = 40) {
 
(6) total
 
= 0 ;(7) subject = 1;8) while (subject < = 5) }(9) Scanf ("Enter marks : % d”, & marks);(10) total = total + marks ;
 
(11) subject ++;(12) }(13) average = total/5 ;(14) if (average > = 50)(15) printf ("Pass... Average marks = % f", average);(16) else(17) print ("FAIL ... Average marks are % f”, average) ;(18) num_student ++;(19) }(20) printf ("end of program") ;(21) }
Process of constructing the flow graph:Step – 1:
Start dividing the program into parts where flow of control has single entry and exit point. In thisprogram, line number 2 to 4 are grouped as one node (marked as 'a') only. This is because it consists of declaration and initialization of variables. The second part comprises of a while loop-outer one, from lines 5 to19 and the third part is a single “printf” statement at line number 20.Here the second part is again divided into four parts-statements of line 6 and 7, lines 8 to 12, line 13 and lines14-17 i.e. “if-then-else” structure using the flow graph notation, we get this flow graphHere,
“ * ''
indicates that the node is a predicate node i.e., it has an out-degree of 2.The statements corresponding to various nodes are as under 
NodesStatement No.
a2-4b5e6-7f8z9-12g13-14h15i17 j18c19d20
 
Step – 2:
Calculation of Cyclomatic Complexity V(G) by three methods
Method – 1:
V(G) = e – n + 2 ( Where “e” are edges & “n” are nodes)V(G) = 14– 11 + 2 = 3 + 2 = 5
Method – 2:
V(G) = P + 1 (Where P – No. of predicate nodes with out degree = 2)
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...