Basis Path, cyclometric complexity, and control flow graphs

Fascinating subject.

quoting from here:

“McCabe’s Basis Path Testing
Steps:
1: Draw a control flow graph
2: Calculate Cyclomatic complexity
3: Choose a “basis set” of paths
4: Generate test cases to exercise each path”

reading through, the basis set of paths, a little little like the critical path, is an important stage for testing your code:

“Choose a set of basis paths – Determining the predicate nodes can help
identify a set of basis paths. If test cases can be designed to cover the
basis path set, it will result in complete decision (and statement)
coverage of the code. Each basis path that you select must in effect test
at least one new untested edge, in other words it must traverse at least
one new edge. Otherwise it is considered a redundant path and does not
belong in the basis set. This aids in eliminating redundant testing and
ensures validity of each test case. For each subsequent basis path
selected try to keep the number of new edges added as low as possible –
progressing on until you have covered all possible basis paths.”

Hang on a min there – what is it exactly? Scrathcylde comes to the help:

if ( p1 ) a; else b; if ( p2 ) c; else d;

“Basis path testing only includes independent paths–each path must introduce an edge that has not been traversed previously.In our example a maximum of 3 tests will do this (number of conditions + 1).In fact could be covered by 2 tests e.g. ac and bd.”

Ah-ha.

2 Comments »

  1. alex said,

    January 11, 2007 @ 6:25 pm

    This is a test.

  2. Administrator said,

    January 11, 2007 @ 6:28 pm

    a test on my test comment

RSS feed for comments on this post · TrackBack URI

Leave a Comment