Basis Path Testing
Basis Path Testing
Basis Path Testing
The Basis path method enables to derive a logical complexity measure of a procedural design and use this measure as a guide for defining a basis set of execution paths. Test Cases derived to exercise the basis set are guaranteed to execute every statement in the program at least one time during testing. Designing Test Cases There are various techniques in which you can design test cases. For example, the below illustrated gives you an overview as to how you derive test cases using the basis path method The basis path testing method can be applied to a procedural design or to source code. The following steps can be applied to derive the basis set !. "se the design or code as a foundation, draw corresponding flow graph. #. $etermine the Cyclomatic complexity of the resultant flow graph. %. $etermine a basis set of linearly independent paths. &. 'repare test cases that will fore execution of each path in the basis set. (et us now see how to design test cases in a generic manner !. "nderstand the requirements document. #. Brea) the requirements into smaller requirements *if it improves your testability+. %. For each ,equirement, decide what technique you should use to derive the test cases. For example, if you are testing a (ogin page, you need to write test cases basing on error guessing and also negative cases for handling failures. &. -ave a Traceability Matrix as follows ,equirement .o */n ,$+ ,equirement Test Case .o 0hat this Traceability Matrix provides you is the coverage of Testing. 1eep filling in the Traceability matrix when you complete writing test case2s for each requirement.
Basis Path Testing 3 testing mechanism proposed by McCabe. 3im 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. Flow Graph Notation .otation for representing control flow
4n a flow graph 3rrows called edges represent flow of control Circles called nodes represent one or more actions. 3reas bounded by edges and nodes called regions. 3 predicate node is a node containing a condition 3ny procedural design can be translated into a flow graph. .ote that compound boolean expressions at tests generate at least two predicate node and additional arcs.
5xample !.%.# 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. 3n 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+
5xample has Cyclomatic Complexity of &. Can be calculated as .umber of regions of flow graph. 65dges 7 6.odes 8 6terminal vertices *usually #+ 6'redicate .odes 8 ! /ndependent 'aths !, 9 !, #, %, :b, !, 9 !, #, &, ;, :a, :b, !, 9 !, #, &, <, :a, :b, !, 9
Cyclomatic complexity provides upper bound for number of tests required to guarantee coverage of all program statements. !.%.% $eriving Test Cases "sing the design or code, draw the corresponding flow graph. $etermine the cyclomatic complexity of the flow graph. $etermine a basis set of independent paths. 'repare test cases that will force execution of each path in the basis set. .ote some paths may only be able to be executed as part of another test.