İstanbul evden eve nakliyat Beylikd¨Ήz¨Ή evden eve nakliyat Tuzla evden eve nakliyat
Tutorial-3 Estimation of Complexity Measure V-G For a program evaluating Examination of Students
Delicious Bookmark this on Delicious
software testing genius

Tutorial-3 Estimation of Complexity Measure V-G For a program evaluating Examination of Students

Welcome to “Software Testing Genius”. Subscribe to my RSS feed for latest content on Software Testing.

Tutorial-3: Estimation of Complexity Measure V(G): For a program evaluating Examination of Students

In this tutorial, the program inputs the marks of five subject of
40 students and outputs average marks and the pass / fail message.



Objective of the Tutorial: To draw a Flow Graph, find its Cyclomatic Complexity, V(G) and the independent paths 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 paths to 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 Following Tutorial on :

Flow Graph and its Notations

Step – 2: Identify independent paths.


Step – 3:
Calculate Cyclomatic Complexity, V(G).


Step – 4:
 Design the test cases.

 

Objective of the Tutorial: To draw a Flow Graph, find its Cyclomatic Complexity, V(G) and the independent paths for the following piece of code.

     
# include


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 this program, 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 to 19 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 lines 14-17 i.e. “if-then-else” structure using the flow graph notation, we get this flow graph

 

 

Here, “ * '' 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


Nodes

Statement No.

a

2-4

b

5

e

6-7

f

8

z

9-12

g

13-14

h

15

i

17

j

18

c

19

d

20




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)

V(G) = 4 + 1 = 5   (Nodes b, f, g & c are predicate nodes with 2 outgoing edges)


Method – 3: V(G) = Number of enclosed regions + 1 = 4+1=3
( Here R1 – R4 are enclosed regions and 1 corresponds to one outer region)

V(G) = 5 and is same by all the three methods.

 

Step – 3: Identification of the basis-set with five paths

 

Path 1:

a – b – d – e

Path 2:

a – b – d – f – n –  b – d – e

Path 3:

a – b – c – g – j – k – m – n –  b – d – e

Path 4:

a – b – c – g – j – l – m – n –  b – d – e

Path 5:

a – b – c – g – h – i – n –  b – d – e

 

Conclusions from the above tutorial:

Conclusion – 1: Each of these paths consists of at least one new edge. Hence this basis set of paths is NOT unique.

 

Conclusion – 2: Test cases should be designed for the independent path execution as identified above.

 

Conclusion – 3: We must execute these paths at least once in order to test the program thoroughly.

Many more Articles & Tutorials on White Box Testing

Largest Database of Sample Papers - 1000+ Unique Questions for ISTQB Foundation Exam

ISTQB Foundation Exam - Full Crash Course for Download

ISTQB Advanced CTAL Test Analysts Exam - Full Crash Course for Download


ISTQB Advanced CTAL Test Manager Exam - Full Crash Course for Download


What Successful Testers say about the Quality of this website

If you want to keep track of further articles on Software Testing,
I suggest you to subscribe my
RSS feed
.

You can also Subscribe by E-mail
and get All New articles delivered directly to your Inbox.

Get your Absolutely Free Copy of Several MS PowerPoint Presentations & E-Books related to ISTQB, HP Load Runner, IBM RFT, HP QTP & QC Certification Exams, prepared by Popular Writers & Trainers, by writing to: Software.testing.genius@gmail.com

Full Study Material for Popular Certification Exams:

Study Material - HP QTP & QC Certification Exam

Study Material - IBM RFT Certification Exam

Study Material - HP LoadRunner Certification Exams for All Modules

Study Material - ISTQB Certification Exam

Most Popular Topics in Demand:

Practical Roadmap to QTP Certification

Practical Roadmap to CSTE Certification

Consolidated Study Material - Testing & QA

Rehearsal of QTP in 1 Hr. -  Interview Questions

 

Comments :

comments ↓


Leave Your Comments: (*) Marked Fields are Mandatory

You can apply basic formatting to the text

Name *
 
Email Address *
 
Website
 
Speak your mind
characters
sex hikayeleri