10
Presentation on Path Testing © Sun Technologies Inc. 1 AGENDA

Path Testing

Embed Size (px)

Citation preview

Page 1: Path Testing

Presentation onPath Testing

© Sun Technologies Inc. 1

AGENDA

Page 2: Path Testing

Path Testing

Path testing is a White box testing technique which ensures that every path in a program has

been executed at least once.

• It requires complete knowledge of program structure.

• It is most often used by programmers to test their own code.

Why do we need Path Testing?

Goal of the path testing is to pick enough paths to ensure that every source statement is

executed at least once and to eliminate the redundant code.

© Sun Technologies Inc. 2

Page 3: Path Testing

• Converting the Programming Language to directed graph• Converting Directed graph to DD-Path (Decision to Decision)• Determine the Cyclomatic Complexity• Determine the Basis set of Independent paths

© Sun Technologies Inc. 3

Path Testing Steps

Page 4: Path Testing

© Sun Technologies Inc. 4

• 1 setDays = 0

• 2 availDays = 4

• 3 input = InputBox ("enter the selection 1: Paid Leave 2: LOP")

• 4 if (input=1) then

• 5 setDays = InputBox ("Enter the required number of paid leave")

• 6 if (setDays<=4 and setDays>0) Then

• 7 availDays = availDays - setDays

• 8 MsgBox("Paid Leave approved." &chr(13) &"Remaining Paid Leaves : "&availDays)

• 9 elseIf ((setDays > availDays) AND (availDays<>0)) Then

• 10 MsgBox ("Enter Valid days for leave")

• 11 elseif (setDays<=0) then

• 12 MsgBox("Enter Valid days for leave")

• 13 End If

• 14 elseif (input=2) then

• 15 setDays = InputBox ("Enter the required number of LOP ")

• 16 if (setDays>0) then

• 17 MsgBox ("LOP approved.")

• 18 else MsgBox ("Enter valid days for leave")

• 19 end if

• 20 else msgbox ("no selection")

• 21 end if

HRM Application with Directed Graph

Page 5: Path Testing

© Sun Technologies Inc. 2

DD Path

Directed Graph DD Path

Page 6: Path Testing

Case1: It consist of a single node with indeg=0Case2: It consist of a single node with outdeg=0Case3: It consist of a single node with indeg>=2 or Outdeg>=2Case4: It consist of a single node with indeg=1 and Outdeg=1Case5: It is maximal chain of length>=1

© Sun Technologies Inc. 6

DD path case:

Page 7: Path Testing

Cyclomatic complexity is a software metric (measurement), used to indicate the complexity of a program.

V(G)=E-N+2P

E-Number of EdgesN-Number of NodesP-Number of connected Region

© Sun Technologies Inc. 7

Determine Cyclomatic Complexity:

Page 8: Path Testing

No of Edges=20No of Nodes=16Connected Region=1

V(G)=E-N+2PV(G)=20-16+2(1) = 4+2

V(G) = 6

Hence the number of paths for the given program will be

© Sun Technologies Inc. 8

Determine Cyclomatic Complexity:

Page 9: Path Testing

i. P1: First, A,B,C,D,E,H,Last ii. P2: First, A,B,C,D,F,H,Last iii. P3: First, A,B,C,D,G,H,Last iv. P4: First,A,B,I,J,K,M,Lastv. P5: First,A,B,I,J,L,M,Lastvi. P6: First,A,B,N,Last

© Sun Technologies Inc. 9

Paths covered in the program

Page 10: Path Testing

THANK YOU

© Sun Technologies Inc. 10