In [[software engineering]], '''basis path testing''', or '''structured testing''',<ref name="nist">{{cite web|
<gallery>
url=http://www.mccabe.com/pdf/mccabe-nist235r.pdf| title=Structured Testing: A Testing Methodology Using the Cyclomatic Complexity Metric| author=Arthur H. Watson and Thomas J. McCabe| year=1996|publisher=NIST Special Publication 500-235}}</ref> is a [[White-box testing|white box method]] for designing [[test case (software)|test case]]s. The method analyzes the [[control-flow graph]] of a program to find a set of linearly independent paths of [[execution (computing)|execution]]. The method normally uses McCabe [[cyclomatic complexity]] to determine the number of linearly independent paths and then generates test cases for each path thus obtained.<ref name="Westfall2008">{{cite book|author=Linda Westfall|title=The Certified Software Quality Engineer Handbook|year=2008|publisher=ASQ Quality Press|isbn=978-0-87389-730-3|pages=436–437}}</ref> Basis path testing guarantees complete [[branch coverage]] (all edges of the [[control-flow graph]]), but achieves that without covering all possible [[Path (graph theory)|paths]] of the control-flow graph{{snd}} the latter is usually too costly.<ref name="SrikantShankar2002">{{cite book|author1=Y.N. Srikant|author2=Priti Shankar|title=The Compiler Design Handbook: Optimizations and Machine Code Generation|year=2002|publisher=CRC Press|isbn=978-1-4200-4057-9|page=249}}</ref> Basis path testing has been widely used and studied.<ref name="Binder2000">{{cite book|author=Robert V. Binder|title=Testing Object-oriented Systems: Models, Patterns, and Tools|year=2000|publisher=Addison-Wesley Professional|isbn=978-0-201-80938-1|page=[https://archive.org/details/testingobjectori00bind/page/378 378]|url-access=registration|url=https://archive.org/details/testingobjectori00bind/page/378}}</ref>
File:http://users.csc.calpoly.edu/~jdalbey/206/Lectures/BasisPathTutorial/diag8-5b.gif|Caption1
File:Example.jpg|Caption2
</gallery>
[[File:]][[File:http://users.csc.calpoly.edu/~jdalbey/206/Lectures/BasisPathTutorial/diag8-5b.gif]]{{notability|date=May 2012}}
'''Basis path testing''', or '''structured testing''' is a method for designing test cases intended to examine each mathematically possible path of execution at least once.
==See also==
* [[Decision-to-decision path|DD-path]] testing
* [[Cyclomatic complexity]]
==References==
== External links ==
{{reflist}}
* [http://hissa.nist.gov/basicpathtest/ What is Basis Path Testing?] from the National Institute for Science and Technology
==Further reading==
* {{cite book|author=Paul C. Jorgensen|title=Software Testing: A Craftsman's Approach, Second Edition|year=2002|publisher=CRC Press|isbn=978-0-8493-0809-3|pages=146–150}}
* {{cite book|author1=Alan Page|author2=Ken Johnston|author3=Bj Rollison|title=How We Test Software at Microsoft|year=2008|publisher=Microsoft Press|isbn=978-0-7356-3831-0|at=chapter 6}}
[[Category:Software testing]]
1.3 Basis Path Testing
A testing mechanism proposed by McCabe.
Aim is to derive a logical complexity measure of a procedural design and use this as a guide for defining a basic set of execution paths.
Test cases which exercise basic set will execute every statement at least once.
1.3.1 Flow Graph Notation
Notation for representing control flow
[Diagrams for control flow types]
On a flow graph:
Arrows called edges represent flow of control
Circles called nodes represent one or more actions.
Areas bounded by edges and nodes called regions.
A predicate node is a node containing a condition
Any procedural design can be translated into a flow graph.
Note that compound boolean expressions at tests generate at least two predicate node and additional arcs.
Example:
[Diagram for mapping from a procedural design to a flow graph]
1.3.2 Cyclomatic Complexity
The cyclomatic complexity gives a quantitative measure of the logical complexity.
This value gives the number of independent paths in the basis set, and an upper bound for the number of tests to ensure that each statement and both sides of every condition is executed at least once.
An independent path is any path through a program that introduces at least one new set of processing statements (i.e., a new node) or a new condition (i.e., a new edge)
1: WHILE NOT EOF LOOP
2: Read Record;
2: IF field1 equals 0 THEN
3: Add field1 to Total
3: Increment Counter
4: ELSE
4: IF field2 equals 0 THEN
5: Print Total, Counter
5: Reset Counter
6: ELSE
6: Subtract field2 from Total
7: END IF
8: END IF
8: Print "End Record"
9: END LOOP
9: Print Counter
[Diagram for flow graph of a procedure]<="" p="">
Example has:
Independent Paths:
1, 9
1, 2, 3, 8, 1, 9
1, 2, 4, 5, 7, 8, 1, 9
1, 2, 4, 6, 7, 8, 1, 9
Cyclomatic Complexity of 4; computed using any of these 3 formulas:
#Edges - #Nodes + #terminal vertices (usually 2)
#Predicate Nodes + 1
Number of regions of flow graph.
Cyclomatic complexity provides upper bound for number of tests required to guarantee coverage of all program statements.
Could we omit path #1 since it's covered in #2?
1.3.3 Deriving Test Cases
Using the design or code, draw the corresponding flow graph.
Determine the cyclomatic complexity of the flow graph.
Determine a basis set of independent paths.
Prepare test cases that will force execution of each path in the basis set.
Note: some paths may only be able to be executed as part of another test.
|