Presentation on
Path Testing
© Sun Technologies Inc. 1
AGENDA
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
• 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
© 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
© Sun Technologies Inc. 2
DD Path
Directed Graph DD Path
Case1: It consist of a single node with indeg=0
Case2: It consist of a single node with outdeg=0
Case3: It consist of a single node with indeg>=2 or Outdeg>=2
Case4: It consist of a single node with indeg=1 and Outdeg=1
Case5: It is maximal chain of length>=1
© Sun Technologies Inc. 6
DD path case:
Cyclomatic complexity is a software metric (measurement), used to
indicate the complexity of a program.
V(G)=E-N+2P
E-Number of Edges
N-Number of Nodes
P-Number of connected Region
© Sun Technologies Inc. 7
Determine Cyclomatic Complexity:
No of Edges=20
No of Nodes=16
Connected Region=1
V(G)=E-N+2P
V(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:
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,Last
v. P5: First,A,B,I,J,L,M,Last
vi. P6: First,A,B,N,Last
© Sun Technologies Inc. 9
Paths covered in the program
THANK YOU
© Sun Technologies Inc. 10

Path Testing

  • 1.
    Presentation on Path Testing ©Sun Technologies Inc. 1 AGENDA
  • 2.
    Path Testing Path testingis 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
  • 3.
    • Converting theProgramming 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
  • 4.
    © Sun TechnologiesInc. 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
  • 5.
    © Sun TechnologiesInc. 2 DD Path Directed Graph DD Path
  • 6.
    Case1: It consistof a single node with indeg=0 Case2: It consist of a single node with outdeg=0 Case3: It consist of a single node with indeg>=2 or Outdeg>=2 Case4: It consist of a single node with indeg=1 and Outdeg=1 Case5: It is maximal chain of length>=1 © Sun Technologies Inc. 6 DD path case:
  • 7.
    Cyclomatic complexity isa software metric (measurement), used to indicate the complexity of a program. V(G)=E-N+2P E-Number of Edges N-Number of Nodes P-Number of connected Region © Sun Technologies Inc. 7 Determine Cyclomatic Complexity:
  • 8.
    No of Edges=20 Noof Nodes=16 Connected Region=1 V(G)=E-N+2P V(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:
  • 9.
    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,Last v. P5: First,A,B,I,J,L,M,Last vi. P6: First,A,B,N,Last © Sun Technologies Inc. 9 Paths covered in the program
  • 10.
    THANK YOU © SunTechnologies Inc. 10