basis path testing
TRANSCRIPT
![Page 1: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/1.jpg)
BASIC PATH TESTING
HOA LE
![Page 2: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/2.jpg)
Agenda
Introduction Cyclomatic complexity Basic path testing approach Conclusion
![Page 3: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/3.jpg)
Introduction
A white box method Proposed by McCabe in 1980’s A hybrid of path testing and branch
testing methods. Based on Cyclomatic complexity and
uses control flow to establish the path coverage criteria.
![Page 4: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/4.jpg)
Cyclomatic Complexity
Developed by McCabe in 1976 Measures the number of linearly
independent paths through a program. The higher the number the more complex
the code.
![Page 5: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/5.jpg)
Basic path testing approach
Step 1: Draw a control flow graph. Step 2: Determine Cyclomatic complexity. Step 3: Find a basis set of paths. Step 4: Generate test cases for each path.
![Page 6: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/6.jpg)
Draw a control flow graph
Basic control flow graph structures:
![Page 7: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/7.jpg)
Draw a control flow graph
Arrows or edges represent flows of control.Circles or nodes represent actions.Areas bounded by edges and nodes are called regions.A predicate node is a node containing a condition.
![Page 8: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/8.jpg)
Draw a control flow graph
1: IF A = 100 2: THEN IF B > C 3: THEN A = B 4: ELSEA= C 5: ENDIF 6: ENDIF 7: Print A
![Page 9: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/9.jpg)
Determine Cyclomatic complexity
There are several methods:
1. Cyclomatic complexity = edges - nodes + 2p
2. Cyclomatic complexity= Number of Predicate Nodes + 1
3. Cyclomatic complexity =number of regions in the control flow graph
![Page 10: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/10.jpg)
Determine Cyclomatic complexityCyclomatic complexity = edges - nodes
+ 2p p = number of unconnected parts of the
graph.
Cyclomatic complexity = 8-7+ 2*1= 3.
![Page 11: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/11.jpg)
Determine Cyclomatic complexityCyclomatic complexity = edges -
nodes + 2p
Cyclomatic complexity = 7-8+ 2*2= 3.
![Page 12: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/12.jpg)
Determine Cyclomatic complexity
Cyclomatic complexity= Number of Predicate Nodes + 1
Cyclomatic complexity = 2+1= 3.
![Page 13: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/13.jpg)
Determine Cyclomatic complexityCyclomatic complexity =number of
regions in the control flow graph
Cyclomatic complexity = 3
![Page 14: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/14.jpg)
Find a basis set of paths
Path 1: 1, 2, 3, 5, 6, 7.
Path 2: 1, 2, 4, 5, 6, 7.
Path 3: 1, 6, 7.
![Page 15: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/15.jpg)
Generate test cases for each path
We have 3 paths so we need at least one test case to cover each path.
Write test case for these paths .
![Page 16: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/16.jpg)
Conclusion
Basic path testing helps us to reduce redundant tests.
It suggests independent paths from which we write test cases needed to ensure that every statement and condition can be executed at least one time.
![Page 17: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/17.jpg)
References W. Xibo and S. Na, "Automatic test data
generation for path testing using genetic algorithms," in Measuring Technology and Mechatronics Automation (ICMTMA), 2011 Third International Conference on, vol. 1, pp. 596-599, IEEE, 2011..
B. Smith and L. A. Williams, "A survey on code coverage as a stopping criterion for unit testing," 2008.
E. L. Lloyd and B. A. Malloy, "A study of test coverage adequacy in the presence of stubs," Journal of Object Technology, vol. 4, no. 5, pp. 117-137,2005.
![Page 18: Basis path testing](https://reader035.vdocuments.net/reader035/viewer/2022070601/589995dc1a28ab30328b6ca3/html5/thumbnails/18.jpg)