0% found this document useful (0 votes)
231 views18 pages

Basis Path Testing

This document discusses basic path testing, which is a white box testing method based on cyclomatic complexity. It uses control flow graphs to establish path coverage criteria. The document outlines how to perform basic path testing: (1) draw a control flow graph, (2) determine cyclomatic complexity, (3) find a basis set of independent paths, and (4) generate test cases to cover each path. The goal is to ensure every statement and condition is executed at least once.

Uploaded by

topher
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)
231 views18 pages

Basis Path Testing

This document discusses basic path testing, which is a white box testing method based on cyclomatic complexity. It uses control flow graphs to establish path coverage criteria. The document outlines how to perform basic path testing: (1) draw a control flow graph, (2) determine cyclomatic complexity, (3) find a basis set of independent paths, and (4) generate test cases to cover each path. The goal is to ensure every statement and condition is executed at least once.

Uploaded by

topher
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
You are on page 1/ 18

BASIC PATH

TESTING
HOA LE
Agenda

Introduction
Cyclomatic complexity
Basic path testing approach
Conclusion
Introduction

A white box method


Proposed by McCabe in 1980s
A hybrid of path testing and branch
testing methods.
Based on Cyclomatic complexity and
uses control flow to establish the path
coverage criteria.
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.
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.
Draw a control flow graph

Basic control flow graph structures:


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.
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
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
Determine Cyclomatic complexity

Cyclomatic complexity = edges - nodes + 2p


p = number of unconnected parts of the
graph.

Cyclomatic
complexity =
8-7+ 2*1= 3.
Determine Cyclomatic complexity
Cyclomatic complexity = edges - nodes
+ 2p

Cyclomatic complexity
= 7-8+ 2*2= 3.
Determine Cyclomatic complexity

Cyclomatic complexity= Number of


Predicate Nodes + 1

Cyclomatic complexity
= 2+1= 3.
Determine Cyclomatic complexity
Cyclomatic complexity =number of regions in
the control flow graph

Cyclomatic complexity
=3
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.
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 .
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.
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.

You might also like