Download presentation

Presentation is loading. Please wait.

Published byJaheem Mulford Modified over 3 years ago

1
**Path Analysis Why path analysis for test case design?**

Provides a systematic methodology. Reproducible Traceable Countable What is path analysis? Analyzes the number of paths that exist in the system Facilitates the decision process of how many paths to include in the test

2
**Linearly Independent Path**

A path through the system is Linearly Independent** from other paths only if it includes some segment that is not covered in the other path. S1 - The statements are represented by the rectangular and diamond blocks. - The segments between the blocks are labeled with numbered circles. 1 2 C1 Path1 : S1 – C1 – S3 Path2 : S1 – C1 – S2 – S3 OR Path1: segments (1,4) Path2: segments (1,2,3) 4 S2 3 S3 Path1 and Path2 are linearly independent because each includes some segment that is not included in the other. ** This definition will require more explanation later.

3
**Another Example of Linearly Independent Paths**

1 S2 8 C1 2 Path1: segments (1,2,8) Path2: segments (1,5,3,9) Path3: segments (1,5,6,4,10) Path4: segments (1,5,6,7) Note that these are all linearly independent 5 C2 3 S3 9 6 C3 4 10 S4 7 S5

4
**Statement Coverage Method**

Count all the linearly independent paths Pick the minimum number of linearly independent paths that will include all the statements (S’s and C’s in the diagram) S1 Path1 : S1 – C1 – S3 Path2 : S1 – C1 – S2 – S3 1 2 C1 4 S2 3 S3 Path1 and Path2 are needed to cover all the statements: (S1,C1,S2,S3) ?

5
**Another Example of Statement Coverage**

1 S2 8 C1 2 The 4 Linearly Independent Paths Covers: Path1: includes S1-C1-S2-S5 Path2: includes S1-C1-C2-S3-S5 Path3: includes S1-C1-C2-C3-S4-S5 Path4: includes S1-C1-C2-C3-S5 5 C2 3 S3 9 6 C3 4 10 S4 7 S5 For 100% Statement Coverage, all we need are 3 paths : Path1, Path2, and Path3 to cover all the statements (S1,C1,S2,C2,S3,C3,S4,S5) no need for Path

6
**Branch Coverage Method**

Identify all the decisions Count all the branches from the each of the decisions Pick the minimum number of paths that will cover all the branches from the decisions.

7
**Branch Coverage Method**

S1 Decision C1 : B1 : Path1 : C1 – S3 B2 : Path2 : C1 – S2 – S3 1 Branch 1 C1 Branch 2 2 4 S2 3 S3 Path1 and Path2 are needed to cover both branches from C1?

8
**Another Example of Branch Coverage**

The 3 Decisions: C1: - B1 : C1- S2 - B2 : C1- C2 C2: - B3 : C2 – S3 - B4 : C2 – C3 C3: - B5 : C3 – S4 - B6 ; C3 – S5 S1 1 S2 8 C1 2 5 C2 3 S3 9 6 C3 4 10 S4 The 4 Linearly Independent Paths Covers: Path1: includes S1-C1-S2-S5 Path2: includes S1-C1-C2-S3-S5 Path3: includes S1-C1-C2-C3-S4-S5 Path4: includes S1-C1-C2-C3-S5 7 S5 We need: Path1 to cover B1, Path2 to cover B2 and B3, Path3 to cover B4 and B5, Path4 to cover B6

9
**McCabe’s Cyclomatic Number**

Is there a way to know how many linearly independent paths exist? McCabe’s Cyclomatic number used to study program complexity may be applied. There are 3 ways to get the Cyclomatic Complexity number from a flow diagram. # of binary decisions + 1 # of edges - # of nodes + 2 # of closed regions + 1 Reference: T.J. McCabe, “A complexity Measure,” IEEE Transactions on Software Engineering, Dec. 1976

10
**McCabe’s Cyclomatic Complexity Number Earlier Example**

We know there are 2 linearly independent paths from before: Path1 : C1 – S3 Path2 : C1 – S2 – S3 S1 1 McCabe’s Cyclomatic Number: a) # of binary decisions +1 = 1 +1 = 2 b) # of edges - # of nodes +2 = = 2 c) # of closed regions + 1 = = 2 C1 2 4 Closed region S2 3 S3

11
**McCabe’s Cyclomatic Complexity Number Another Example**

McCabe’s Cyclomatic Number: a) # of binary decisions +1 = 2 +1 = 3 b) # of edges - # of nodes +2 = = 3 c) # of closed regions + 1 = = 3 S1 1 4 C1 2 C2 5 S2 There are 3 Linearly Independent Paths Closed Region Closed Region S4 7 6 3 S3

12
**An example of 2n total path**

Since for each binary decision, there are 2 paths and there are 3 in sequence, there are 23 = 8 total “logical” paths path1 : S1-C1-S2-C2-C3-S4 path2 : S1-C1-S2-C2-C3-S5 path3 : S1-C1-S2-C2-S3-C3-S4 path4 : S1-C1-S2-C2-S3-C3-S5 path5 : S1-C1-C2-C3-S4 path6 : S1-C1-C2-C3-S5 path7 : S1-C1-C2-S3-C3-S4 path8 : S1-C1-C2-S3-C3-S5 S1 1 C1 2 3 S2 4 C2 5 6 S3 How many Linearly Independent paths are there? Using Cyclomatic number = 3 decisions +1 = 4 One set would be: path1 : includes segments (1,2,4,6,9) path2 : includes segments (1,2,4,6,8) path3 : includes segments (1,2,4,5,7,9) path5 : includes segments (1,3,6,9) 7 C3 9 8 S5 S4 Note 1: with just 2 paths ( Path1 and Path8) all the statements are covered. Note2: with just 2 paths ( Path1 and Path8) all the branches are covered.

13
Example with a Loop Total number of paths may be “ infinite” (very large) because of the loop S1 1 Linearly Independent Paths = 1 decision +1 = 2 path1 : S1-C1-S3 (segments 1,4) path2 : S1-C1-S2-C1-S3 (segments 1,2,3,4) C1 4 S3 2 One path will cover all statements: (S1,C1,S2, S3) path2 : S1-C1-S2-C1-S3 S2 3 One path will cover all branches: path2 : S1-C1-S2-C1-S3 branch1 (C1-S2) and branch 2 (C1-S3)

14
**More on Linearly Independent Paths**

In discussing dimensionality, we talks about orthogonal vectors. Two dimensional space has two orthogonal vector from which all the other vectors in two dimension can be obtained via “linear combination” of these vectors: [1,0] [0,1] e.g. [2,4] = 2[1,0] + 4[0,1] [2,4] [1,0] [0,1]

15
**More on Linearly Independent Paths**

A set of paths is considered to be a Linearly Independent Set if every path may be constructed as a “linear combination” of paths from the linearly independent set. For example: We already know: a) there are a total of 22=4 logical paths. b) 2 paths that will cover all statements and all branches. c) 2 branches +1 = 3 linearly independent paths. C1 2 1 S1 1 2 3 4 5 6 3 We picked path1, path2 and path3 as The Linearly Independent Set path1 1 1 1 C2 5 path2 1 1 4 path3 1 1 1 S1 path4 1 1 1 1 6 path 4 = path3 + path1 – path2 = (0,1,1,1,0,0)+(1,0,0,0,1,1)- (1,0,0,1,0,0) = (1,1,1,1,1,1) - (1,0,0,1,0,0) = (0,1,1,0,1,1)

16
**More on Linearly Independent Paths**

We already know: a) there are a total of 22=4 logical paths. b) 2 paths that will cover all statements and all branches. c) 2 branches +1 = 3 linearly independent paths. C1 2 1 S1 1 2 3 4 5 6 3 path1 1 1 1 C2 5 path2 1 1 4 path3 1 1 1 S1 path4 1 1 1 1 6 Although path1 and path3 are linearly independent, they do NOT form a Linearly Independent Set because no linear combination of path1 and path3 can get , say, path4.

17
**More on Linearly Independent Paths**

Because the Linearly Independent Set of paths display the same characteristics as the mathematical concept of basis in n-dimensional vector space, the testing using the Linearly Independent Set of paths is sometimes called the “basis” testing.

18
**Paths Analysis Interested in Total number of “logical” paths**

Interested in Linearly Independent paths Interest in Branch coverage Interested in Statement coverage Which one is the largest set, next largest set, , etc.?

Similar presentations

OK

Creator: ACSession No: 13 Slide No: 1Reviewer: SS CSE300Advanced Software EngineeringFebruary 2006 Testing - Techniques CSE300 Advanced Software Engineering.

Creator: ACSession No: 13 Slide No: 1Reviewer: SS CSE300Advanced Software EngineeringFebruary 2006 Testing - Techniques CSE300 Advanced Software Engineering.

© 2019 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google