PATH TESTING
This document provides a detailed exploration of white-box testing, specifically focusing on path testing. It outlines essential steps, including deriving flow diagrams, identifying all possible paths, and creating path predicates. Two programming examples illustrate the process, showcasing how to test various paths through conditional structures. The guide emphasizes the importance of thorough test cases and expected results for effective path testing, making it a valuable resource for software developers and testers looking to enhance their testing strategies.
PATH TESTING
E N D
Presentation Transcript
PATH TESTING An Example for White-Box Testing
Path testing • a form of white box testing • steps to complete: • derive the module’s flow diagram • describe all possible paths through the diagram (conditions, loops) • derive path predicates • derive test-cases & results per path
PROGRAM example_1 VAR x , y : NUMBER BEGIN <program> READ ( x , y ); IF ( x > 20) THEN BEGIN <nested if> WRITE abs ( x - y ); IF ( x < y ) THEN WRITE ( “ x smaller y ”) ELSE WRITE ( “ x greater or equal y ” ) END <nested if> ELSE WRITE ( “ x smaller or equal 20 ” ) END <program>
x > 20 x < y The Flow Diagram READ x and y TRUE FALSE “abs ( x - y )” “x smaller or equal 20” TRUE FALSE “x smaller y” “x greater or equal y”
x < y Path 1 READ x and y TRUE FALSE x > 20 “abs ( x - y )” “x smaller or equal 20” TRUE FALSE “x smaller y” “x greater or equal y”
Path 2: READ x and y TRUE FALSE x > 20 “abs ( x - y )” “x smaller or equal 20” TRUE FALSE x < y “x smaller y” “x greater or equal y”
Path 3: READ x and y TRUE FALSE x > 20 “abs ( x - y )” “x smaller or equal 20” TRUE FALSE x < y “x smaller y” “x greater or equal y”
Path 1 • predicate: X < 20 Y no constraints • test-cases: (1) X : 20 Y : 33 (2) X : 4 Y : 1 ... • results: (1) “x smaller or equal 20” • (2) “x smaller or equal 20” • ...
Path 2 • predicate: X > 20 X < Y • test-cases: (1) X : 21 Y : 22 (2) X : 103 Y : 203 ... • results: (1) 1 ; “ x smaller y ” • (2) 100 ; “ x smaller y ” • ...
Path 3 • predicate: X > 20 X > Y • test-cases: (1) X : 21 Y : 21 (2) X : 103 Y : 102 ... • results: (1) 0 ; “ x greater or equal y ” • (2) 1 ; “ x greater or equal y ” • ...
PROGRAM example_2 VAR x , y : NUMBER BEGIN <program> READ ( x , y ); IF ( x > 20) THEN WRITE abs ( x - y ) ELSE WRITE ( “ x smaller or equal 20 “ ); IF ( x < y ) THEN WRITE ( “ x smaller y ”) ELSE WRITE ( “ x greater or equal y “) END <program>