0% found this document useful (0 votes)
7 views23 pages

Software Testing: Path Testing Explained

The document discusses software testing, specifically focusing on basic path testing and cyclomatic complexity. It explains path testing as a method to identify executable paths in code, and introduces cyclomatic complexity as a measure of program stability and understanding. Additionally, it covers graph and connection matrices as tools for automating path testing and calculating cyclomatic complexity.

Uploaded by

arhamk30082005
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)
7 views23 pages

Software Testing: Path Testing Explained

The document discusses software testing, specifically focusing on basic path testing and cyclomatic complexity. It explains path testing as a method to identify executable paths in code, and introduces cyclomatic complexity as a measure of program stability and understanding. Additionally, it covers graph and connection matrices as tools for automating path testing and calculating cyclomatic complexity.

Uploaded by

arhamk30082005
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

Module: Software Engineering

Topic: Software Testing

Kashif Asrar
Lecturer, Final Year Project Coordinator
Computer & Info. Systems Engineering
NED University of Engineering & Technology
Email address: kashifasrar@[Link]
1
What is Basic Path Testing?
Path testing is a structural testing method
that uses the source code of a program in
order to find every possible executable
path.
It helps to determine all faults lying within
a piece of code.
This method is designed to execute all or
selected path through a computer
program.
2
Sequential Statements

1. A=1
2. B=2
3. C=A+B
4. Print(c)

3
If-else Statements
If A>B:
print(A)
Else:
print(B)

4
Case Statements

Case statement:
{
Case-1:Statement-1
Case-II:Statement-2
Case-II1:Statement-3
Default:Statement-2

5
What is Path?

6
Cyclomatic Complexity
 Cyclomatic complexity is a
measurement developed by Thomas
McCabe to determine the stability and
level of confidence in a program.
 It measures the number of linearly-
independent paths through a program
module.
 Programs with lower Cyclomatic
complexity are easier to understand and
less risky to modify.

7
Formula for Cyclomatic Complexity
1. No. of edges – No. of nodes +2
2. No. of predicate node +1
3. # of regions +1

8
Example-1 (If-Else) on board

9
Example-2 (If-Else) on board

10
Example-3 (Switch case) on board

11
Graph Matrix
 A graph matrix is a data structure that
can assist in developing a tool for
automation of path testing.
 Properties of graph matrices are
fundamental for developing a test tool
 Hence graph matrices are very useful in
understanding software testing concepts
and theory.

12
Graph Matrix

13
Graph Matrix
 Let’s convert this control flow graph into a graph matrix.
Since the graph has 4 nodes, so the graph matrix would have
a dimension of 4 X 4. Matrix entries will be filled as follows :
• (1, 1) will be filled with ‘a’ as an edge exists from node 1 to
node 1
• (1, 2) will be filled with ‘b’ as an edge exists from node 1 to
node 2. It is important to note that (2, 1) will not be filled as
the edge is unidirectional and not bidirectional
• (1, 3) will be filled with ‘c’ as edge c exists from node 1 to
node 3
• (2, 4) will be filled with ‘d’ as edge exists from node 2 to node
4
• (3, 4) will be filled with ‘e’ as an edge exists from node 3 to
node 4

14
Graph Matrix

15
Connection Matrix :
 A connection matrix is a matrix defined with
edges weight.
 In simple form, when a connection exists
between two nodes of control flow graph,
then the edge weight is 1, otherwise, it is 0.
 However, 0 is not usually entered in the
matrix cells to reduce the complexity.
 For example, if we represent the above
control flow graph as a connection matrix,
then the result would be :

16
Connection Matrix :

17
Connection Matrix :
 A connection matrix is used to find the cyclomatic
complexity of the control graph.
Although there are three other methods to find the
cyclomatic complexity but this method works well too.
 Following are the steps to compute the cyclomatic
complexity :
1. Count the number of 1s in each row and write it in the end of
the row
2. Subtract 1 from this count for each row (Ignore the row if its
count is 0)
3. Add the count of each row calculated previously
4. Add 1 to this total count
5. The final sum in Step 4 is the cyclomatic complexity of the
control flow graph

18
Connection Matrix :

Reference : [Link]
matrices-in-software-testing/
19
Graph Matrix (On Board)

20
Critical Path
 Critical path method (CPM) is a resource-utilization
algorithm for scheduling a set of project activities.
 The essential technique for using CPM is to construct a
model of the project that includes the following:
✓ A list of all tasks required to complete the project
✓ The dependencies between the tasks
✓ The estimate of time (duration) that each activity will
take to complete

21
Critical Path

[Link]

22
Critical Path Exercise (On Board)

Spring Semester 2020 23

You might also like