More On Paths Supplement to Chapter 4, Graph Theory Path definition - - PowerPoint PPT Presentation

more on paths
SMART_READER_LITE
LIVE PREVIEW

More On Paths Supplement to Chapter 4, Graph Theory Path definition - - PowerPoint PPT Presentation

More On Paths Supplement to Chapter 4, Graph Theory Path definition What is a path? We are in in a graph context MOP2 Path definition 2 What is a path? A path is a sequence of nodes n 1 , n 2 , , n p Each


slide-1
SLIDE 1

More On Paths

Supplement to Chapter 4, Graph Theory

slide-2
SLIDE 2

MOP–2

 What is a path?

 We are in in a graph context

Path definition

slide-3
SLIDE 3

MOP–3

 What is a path?

 A path is a sequence of nodes 〈 n1 , n2 , … , np 〉  Each adjacent pair of nodes is in the set of edges

 We say a path visits the nodes in the sequence

Path definition – 2

"j :1..p #1• (n j,n j+1) $ E

slide-4
SLIDE 4

MOP–4

 What is the length of a path?

Path length definition

slide-5
SLIDE 5

MOP–5

 What is the length of a path?

 The number of edges it contains

#path = #sequence – 1

Path definition

slide-6
SLIDE 6

MOP–6

 What a simple path?

Simple path definition

slide-7
SLIDE 7

MOP–7

Simple path definition – 2

 What a simple path?

 A path from node nj to node nk is simple if

 No node appears more than once

 There is no internal loop

 Exception the end points may be the same

 The entire path may form a loop

slide-8
SLIDE 8

MOP–8

 What useful property do simple paths have?

Simple path useful property

slide-9
SLIDE 9

MOP–9

Simple path useful property – 2

 What useful property do simple paths have?

 Any path is a composition of simple paths

slide-10
SLIDE 10

MOP–10

Test path definition

 What is a test path?

slide-11
SLIDE 11

MOP–11

Test path definition – 2

 What is a test path?

 Starts at a starting node of a control flow graph  Terminates at an exit node of a control flow graph  Possibly of length zero

slide-12
SLIDE 12

MOP–12

Prime path definition

 What is a prime path?

slide-13
SLIDE 13

MOP–13

Prime path definition – 2

 What is a prime path?

 A path from node nj to node nk is prime if

 It is a simple path  It is not a proper sub-path of any other simple path  It is a maximal length simple path

slide-14
SLIDE 14

MOP–14

Prime path – Example 1

 Prime paths

 〈 n1 , n2 , n4 〉  〈 n1 , n3 , n4 〉

slide-15
SLIDE 15

MOP–15

Prime path – Example 2

 Prime paths

 〈 n1 , n2 , n3 〉  〈 n1 , n2 , n4 , n5 〉  〈 n2 , n4 , n5 , n2 〉  〈 n4 , n5 , n2 , n4 〉  〈 n5 , n2 , n4 , n5 〉  〈 n4 , n5 , n2 , n3 〉

slide-16
SLIDE 16

MOP–16

Finding prime paths

 Consider the following graph, what are its prime paths?

slide-17
SLIDE 17

MOP–17

Finding prime paths – length 0 paths

 Start with a list of the nodes

 The ! Indicates that the path cannot be extended

1 [0] 2 [1] 3 [2] 4 [3] 5 [4] 6 [5] 7 [6] !

slide-18
SLIDE 18

MOP–18

Finding prime paths – length 1 paths

 Extend length 0 paths by one edge

 Path 7 cannot be extended  The * indicates a loop – cannot be extended

8 [0, 1] 9 [0, 4] 10 [1, 2] 11 [1, 5] 12 [2, 3] 13 [3, 1] 14 [4, 4] * 15 [4, 6] ! 16 [5, 6] ! 1 [0] 2 [1] 3 [2] 4 [3] 5 [4] 6 [5] 7 [6] !

slide-19
SLIDE 19

MOP–19

Finding prime paths – length 2 paths

 Extend length 1 paths by one edge

 Paths 14, 15 and 16 cannot be extended

17 [0, 1, 2] 18 [0, 1, 5] 19 [0, 4, 6] ! 20 [1, 2, 3] 21 [1, 5, 6] ! 22 [2, 3, 1] 23 [3, 1, 2] 24 [3, 1, 5] 8 [0, 1] 9 [0, 4] 10 [1, 2] 11 [1, 5] 12 [2, 3] 13 [3, 1] 14 [4, 4] * 15 [4, 6] ! 16 [5, 6] !

slide-20
SLIDE 20

MOP–20

Finding prime paths – length 3 paths

 Extend length 2 paths by one edge

 Paths 19 and 21 cannot be extended

25 [0, 1, 2, 3] ! 26 [0, 1, 5, 6] ! 27 [1, 2, 3, 1] * 28 [2, 3, 1, 2] * 29 [2, 3, 1, 5] 30 [3, 1, 2, 3] * 31 [3, 1, 5, 6] ! 17 [0, 1, 2] 18 [0, 1, 5] 19 [0, 4, 6] ! 20 [1, 2, 3] 21 [1, 5, 6] ! 22 [2, 3, 1] 23 [3, 1, 2] 24 [3, 1, 5]

slide-21
SLIDE 21

MOP–21

Finding prime paths – length 4 paths

 Extend length 3 paths by one edge

 Only path 29 be extended and no further extensions

are possible 32 [2, 3, 1, 5, 6] ! 25 [0, 1, 2, 3] ! 26 [0, 1, 5, 6] ! 27 [1, 2, 3, 1] * 28 [2, 3, 1, 2] * 29 [2, 3, 1, 5] 30 [3, 1, 2, 3] * 31 [3, 1, 5, 6] !

slide-22
SLIDE 22

MOP–22

Finding prime paths – Collect paths

 No more paths can be extended.  Collect all the paths that terminate with ! or *  Eliminate any path that is a subset of another path in the list

14 [4, 4] * 19 [0, 4, 6] ! 25 [0, 1, 2, 3] ! 26 [0, 1, 5, 6] ! 27 [1, 2, 3, 1] * 28 [2, 3, 1, 2] * 30 [3, 1, 2, 3] * 32 [2, 3, 1, 5, 6] ! These are the 8 prime paths In the example graph

slide-23
SLIDE 23

MOP–23

Prime path usefulness

 Of what use is a prime path?

slide-24
SLIDE 24

MOP–24

Prime path usefulness – 2

 Of what use is a prime path?

 Reduces the number of test cases for path coverage

slide-25
SLIDE 25

MOP–25

Prime path problem

 What is the problem with prime paths?

slide-26
SLIDE 26

MOP–26

Prime path problem – 2

 What is the problem with prime paths?

 A prime path may be infeasible but contain feasible simple

paths

 In such cases, the prime path is factored into the simple

paths in order that it may be covered by testing

slide-27
SLIDE 27

MOP–27

Round trip path definition

 What is a round trip path?

slide-28
SLIDE 28

MOP–28

Round trip path definition – 2

 What is a round trip path?

 It is a prime path, P  #P > 0  head P = last P

 Recall that P is a sequence of nodes

slide-29
SLIDE 29

MOP–29

Tour definition

 In the context of test paths and graph paths  What is a tour?

slide-30
SLIDE 30

MOP–30

Tour definition – 2

 What is a tour?

 A test path is said to tour a graph path if

 graph-path ⊆ test-path  ⊆ in this context means sub-path – not subset  The test-path must visit the graph-path nodes in exactly

the specified sequence with no intervening nodes

slide-31
SLIDE 31

MOP–31

Tour definition – 3

 The following paths are tours

 〈 n2 , n3 , n4 〉  〈 n2 , n3 , n6 , n4 〉  〈 n2 , n3 , n6 , n3 , n4 〉

slide-32
SLIDE 32

MOP–32

Tour with side trips definition

 What is a tour with side trips?

slide-33
SLIDE 33

MOP–33

Tour with side trips definition – 2

 What is a tour with side trips?

 A tour is restrictive in that many test paths would be

infeasible

 Occurs when loops are in the path  The path 〈 n2 , n3 , n4 〉 would be impossible to tour if the

condition in n3 is such that n6 must be visited at least once

slide-34
SLIDE 34

MOP–34

Tour with side trips definition – 3

 We relax the definition of a tour to include side trips

 Leave the sub-path  But come back to the same node before continuing the sub-

path – e.g. 〈 n2 , n3 , n6 , n3 , n6 , n3 , n4 〉

 Test path tours the graph-path with side trips iff every edge of

the graph-path is followed in the same order

slide-35
SLIDE 35

MOP–35

Tour with detours definition

 What is a tour with detours?

slide-36
SLIDE 36

MOP–36

Tour with detours definition – 2

 We relax the definition of a tour to include detours

 Leave the sub-path  But come back to the node that follows the node

where the sub-path was left – e.g. 〈 n2 , n3 , n6 , n3 , n6 , n4 〉

 Test path tours the graph-path with detours iff every node of

the graph-path is followed in the same order

slide-37
SLIDE 37

MOP–37

Test requirement

 What is a test requirement?

slide-38
SLIDE 38

MOP–38

Test requirement – 2

 What is a test requirement?

 A specific element of a software artifact that a test case

must satisfy or cover.

 Usually come in sets

 Use the abbreviation TR to denote a set of test requirements

slide-39
SLIDE 39

MOP–39

Test requirement – 3

 Test requirements

 Are described with respect to a variety of software artifacts,

including

 Program text  Design components  Specification modeling elements  Even descriptions of the input or output space

slide-40
SLIDE 40

MOP–40

Test requirements – All nodes

 Given the pictured graph and the coverage criterion all nodes  What would be the test requirements?

slide-41
SLIDE 41

MOP–41

Test requirements – All nodes

 Given the pictured graph and the coverage criterion all nodes

 The test requirements is a listing of all the nodes in the

graph, with the implication testing should cover the requirements

 { 0, 1, 2, 3, 4, 5, 6 }

slide-42
SLIDE 42

MOP–42

Coverage criteria

 What is a coverage criterion?

slide-43
SLIDE 43

MOP–43

Coverage criteria

 What is a coverage criterion?

 A coverage criterion is a rule or collection of rules that

impose test requirements on a test set.

 A recipe for generating test requirements in a

systematic way

slide-44
SLIDE 44

MOP–44

Coverage criteria – 2

 Consider the following graph

 What test coverage criteria can we have?

slide-45
SLIDE 45

MOP–45

Coverage criteria – 3

Coverage can be the following

All nodes

All edges

All edge pairs

 More edges not useful

All simple paths

All prime paths

All simple round trips

 1 trip each reachable node

that begins & ends the path

All complete round trips

 All trips each reachable node

All specified paths – as all paths is not feasible

All paths

slide-46
SLIDE 46

MOP–46

Test set

 What is a test set?

slide-47
SLIDE 47

MOP–47

Test set – 2

 What is a test set?

 Satisfies test requirements by visiting every artifact in the

test requirements

slide-48
SLIDE 48

MOP–48

Test set – 3

 Given the test requirements to visit all nodes in the following

set for the pictured graph

 { 0, 1, 2, 3, 4, 5, 6 }

 The following test set satisfies

the test requirements

 { [ 0, 4, 4, 4, 6 ]

, [ 0, 1, 2, 3, 1, 5, 6 ] }

slide-49
SLIDE 49

MOP–49

Best effort touring

 In the context of test requirements  What is a best effort tour?

slide-50
SLIDE 50

MOP–50

Best effort touring – 2

 What is a best effort tour?

 TRtour is a set of test requirements such that

 Paths in a graph that must be covered

 Can be directly toured  TRsidetrips is a set of test requirements

 Paths in a graph that must be covered

 Can be directly toured  Or toured with sidetrips

slide-51
SLIDE 51

MOP–51

Best effort touring – 3

 Trips with detours are rarely considered

 They are less practical than sidetrips in dealing with

infeasible paths

slide-52
SLIDE 52

MOP–52

Best effort touring

 In the context of best effort touring  What is a test set?

slide-53
SLIDE 53

MOP–53

Best effort touring – 3

 A test set T is best effort touring if

 For every path p in TRtour

 Some path in T tours p

 Directly  For every path p in TRsidetrips

 Some path in T tours p either

 Directly  Or with a sidetrip

slide-54
SLIDE 54

MOP–54

Meeting strict requirements

 Each test requirement is met in the strictest possible way

 Which means?

slide-55
SLIDE 55

MOP–55

Meeting strict requirements – 2

 Each test requirement is met in the strictest possible way

 Edges and nodes must be visited in the same order as in

the graph

slide-56
SLIDE 56

MOP–56

Path behaviours

 When test requirements describe paths, we distinguish

three types of path behaviours, what are they?

slide-57
SLIDE 57

MOP–57

Path behaviours– 2

 When test requirements describe paths, we distinguish

three types of path behaviours, what are they?

 Feasible  Specified  Topologically possible

 Just look at paths in the graph

 Ignore conditions

slide-58
SLIDE 58

MOP–58

Path behaviours – 3

 Re-examine the Venn diagram in the context of path testing

Specified behaviour Topologically possible paths Programmed behaviour – feasible paths

slide-59
SLIDE 59

MOP–59

Guidelines

 What is the relationship between program text and each

  • f the following?

 Functional testing  Path testing

slide-60
SLIDE 60

MOP–60

Guidelines – 2

 What is the relationship between program text and each

  • f the following?

Functional testing

 Too far from the program text

Path testing

 Too close to the program text  Obscures feasible and infeasible paths

slide-61
SLIDE 61

MOP–61

Guidelines – 3

 What are the benefits and drawbacks of using path

testing?

slide-62
SLIDE 62

MOP–62

Guidelines – 4

 What are the benefits and drawbacks of using path

testing?

 Gives good measures of quality of testing through

coverage analysis

 Provides set of metrics that cross-check functional testing  Use to resolve gap and redundancy questions

 Missing paths – have gaps  Repeated paths – have redundancy

 Does not give good help in finding test cases

slide-63
SLIDE 63

MOP–63

Guidelines – 5

 What is meant by

 Does not give good help in finding test cases?

slide-64
SLIDE 64

MOP–64

Guidelines – 6

 What is meant by

 Does not give good help in finding test cases?

 Too many paths  Infeasible paths  Need selective coverage

 Loop coverage  Computation coverage  Interesting paths

slide-65
SLIDE 65

MOP–65

Next step

 Use dataflow testing to move out a bit

 Move closer to functional testing  Make use of the functional aspects of a program  Less reliance on physical program structure