0% found this document useful (1 vote)
44 views3 pages

Visio 2016 Key

The document discusses the cyclomatic complexity of a code sample. It calculates the cyclomatic complexity of the code to be 3 based on the number of edges, nodes and exit points in the control flow graph. This means there are 3 possible paths through the code. Minimum 3 test cases are needed, one for each path, to completely test the code. The 3 possible paths are then listed.

Uploaded by

aman
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 (1 vote)
44 views3 pages

Visio 2016 Key

The document discusses the cyclomatic complexity of a code sample. It calculates the cyclomatic complexity of the code to be 3 based on the number of edges, nodes and exit points in the control flow graph. This means there are 3 possible paths through the code. Minimum 3 test cases are needed, one for each path, to completely test the code. The 3 possible paths are then listed.

Uploaded by

aman
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

SENG8040: SOFTWARE TESTING METHODOLOGIES

MIDTERM SECTION #2

Name: Amandeep Singh


Student ID: 8665092
Dated: 20/06/2019
5

6 (a)

6 (b)

10-11

6 (c)

For this CFG line number is 6 is break into 3 parts i.e, parameters of for loop.
For example: for ( 6a; 6b; 6c) 6a: int n=1; 6b: n < (99+1); 6c: n++;
And our exit node is 6b ie., when condition of the loop will not satisfy then flow gets exit from the
loop and there is no any path flow outside of the loop. So the final node will be 6b
The cyclomatic complexity of this function:-

Cyclomatic complexity => M = E – N + 2*P

Where,

E = represents a number of edges in the control flow graph.

N = represents a number of nodes in the control flow graph.

P = represents a number of nodes that have exit points in the control flow graph.

In this case: E=7, N=6, P=1;

M = E – N +2*P

M = 7- 6 + 2(1)

M=1+2  M=3
According to the Cyclomatic Complexity number i.e., 3, there are three possible paths are possible of
the code flow. And there are minimum 3 test cases needed (at least one for each path) in the given
method to test the all the paths. As according to the definition, Cyclomatic complexity of a section of
source code is the number of linearly independent paths through the source code. Mathematically
Cyclomatic Complexity of a structured program is defined with reference to control flow graph of the
program. Cyclomatic complexity is used to determine minimum number of test cases that are
necessary to achieve complete test coverage of a particular program.

Three possible paths are:

56(a)6(b)8(10-11)6(c)6(b) //i.e., Flow goes from both for loop and if statement

56(a)6(b)86(c)6(b) // i.e., Flow goes from for loop but not from if statement.

56(a)6(b) // i.e., Flow doesn’t go from both for loop and if statement.

You might also like