Basis Path Testing in Software Testing - GeeksforGeeks
Basis Path Testing in Software Testing - GeeksforGeeks
Let’s understand each step one by one. 1. Control Flow Graph – A control flow graph
(or simply, flow graph) is a directed graph which represents the control structure of a
program or module. A control flow graph (V, E) has V number of nodes/vertices and E
number of edges in it. A control graph can also have :
Junction Node – a node with more than one arrow entering it.
Decision Node – a node with more than one arrow leaving it.
Region – area bounded by edges and nodes (area outside the graph is also counted
as a region.).
:
Below are the notations used while constructing a flow graph :
Sequential Statements –
:
If – Then – Else –
Do – While –
:
While – Do –
Switch – Case –
:
Cyclomatic Complexity – The cyclomatic complexity V(G) is said to be a measure of
the logical complexity of a program. It can be calculated using three different formulae :
V(G) = e - n + 2*P
where, e = 4, n = 4 and p = 1
So,
= 4 - 4 + 2 * 1
= 2
where, d = 1 and p = 1
So,
= 1 + 1
= 2
= 2
Hence, using all the three above formulae, the cyclomatic complexity obtained remains
same. All these three formulae can be used to compute and verify the cyclomatic
complexity of the flow graph. Note –
1. For one function [e.g. Main( ) or Factorial( ) ], only one flow graph is constructed. If in a
program, there are multiple functions, then a separate flow graph is constructed for
each one of them. Also, in the cyclomatic complexity formula, the value of ‘p’ is set
depending of the number of graphs present in total.
2. If a decision node has exactly two arrows leaving it, then it is counted as one decision
node. However, if there are more than 2 arrows leaving a decision node, it is computed
using this formula :
d = k - 1
:
1. Here, k is number of arrows leaving the decision node.
Independent Paths : An independent path in the control flow graph is the one which
introduces at least one new edge that has not been traversed before the path is defined.
The cyclomatic complexity gives the number of independent paths present in a flow
graph. This is because the cyclomatic complexity is used as an upper-bound for the
number of tests that should be executed in order to make sure that all the statements in
the program have been executed at least once. Consider first graph given above here the
independent paths would be 2 because number of independent paths is equal to the
cyclomatic complexity. So, the independent paths in above first given graph :
Path 1:
A -> B
Path 2:
C -> D
Note – Independent paths are not unique. In other words, if for a graph the cyclomatic
complexity comes out be N, then there is a possibility of obtaining two different sets of
paths which are independent in nature. Design Test Cases : Finally, after obtaining the
independent paths, test cases can be designed where each test case represents one or
more independent paths. Advantages : Basis Path Testing can be applicable in the
following cases:
1. More Coverage – Basis path testing provides the best code coverage as it aims to
achieve maximum logic coverage instead of maximum path coverage. This results in
an overall thorough testing of the code.
2. Maintenance Testing – When a software is modified, it is still necessary to test the
changes made in the software which as a result, requires path testing.
3. Unit Testing – When a developer writes the code, he or she tests the structure of the
program or module themselves first. This is why basis path testing requires enough
knowledge about the structure of the code.
:
4. Integration Testing – When one module calls other modules, there are high chances
of Interface errors. In order to avoid the case of such errors, path testing is performed
to test all the paths on the interfaces of the modules.
5. Testing Effort – Since the basis path testing technique takes into account the
complexity of the software (i.e., program or module) while computing the cyclomatic
complexity, therefore it is intuitive to note that testing effort in case of basis path testing
is directly proportional to the complexity of the software or program.
Recommended Articles
1. Various examples in Basis Path Testing
2. Path Testing in Software Engineering
3. Beta Testing | Software Testing
4. API Testing in Software Testing
5. Software Engineering | Differences between Sanity Testing and Smoke Testing
6. Software Testing | Endurance Testing
7. Software Testing | Dynamic Testing
8. Installation testing in Software Testing
9. Smoke Testing | Software Testing
10. Performance Testing | Software Testing
11. Software Testing | Non-functional Testing
12. Sandwich Testing | Software Testing
13. Software Engineering | Comparison between Regression Testing and Re-Testing
14. Alpha Testing | Software Testing
15. Unit Testing | Software Testing
16. Sanity Testing | Software Testing
17. Gray Box Testing | Software Testing
18. Acceptance Testing | Software Testing
19. Software Testing | Reliability Testing
20. Software Testing | Scalability Testing
21. Software Testing | Manual Testing
22. Software Testing | Scenario Testing
:
23. Software Testing | Configuration Testing
24. Software Testing | Penetration Testing
25. Software Testing | Security Testing
Company
About Us
Careers
In Media
Contact Us
Privacy Policy
Copyright Policy
Advertise with us
Learn
DSA
Algorithms
Data Structures
SDE Cheat Sheet
Machine Learning
CS Subjects
Video Tutorials
Courses
NEWS
:
NEWS
Top News
Technology
Work & Career
Business
Finance
Lifestyle
Knowledge
Languages
Python
Java
CPP
Golang
C#
SQL
Kotlin
Web Development
Web Tutorials
Django Tutorial
HTML
JavaScript
Bootstrap
ReactJs
NodeJs
Contribute
Write an Article
Improve an Article
Pick Topics to Write
Write Interview Experience
:
Write Interview Experience
Internships
Video Internship