Download presentation

Presentation is loading. Please wait.

Published byBrenda Parker Modified about 1 year ago

1
Graph Coverage Criteria Structural Coverage Criteria : Defined on a graph just in terms of nodes and edges Data Flow Coverage Criteria : Requires a graph to be annotated with references to variables 1

2
Coverage Criterion A coverage criterion is simply a recipe for generating test requirements in a systematic way: Coverage Criterion: A coverage criterion is a rule or collection of rules that impose test requirements on a test set. 2

3
Coverage Criterion A coverage criterion is a rule or collection of rules that impose test requirements on a test set. That is, the criterion describes the test requirements in a complete and unambiguous manner. The “flavor criterion” yields a simple strategy for selecting jelly beans. In this case, the set of test requirements, TR, can be formally written out as TR = {flavor = Lemon, flavor = Pistachio, flavor = Cantaloupe, flavor = Pear, flavor = Tangerine, flavor = Apricot} 3

4
Coverage Given a set of test requirements TRfor a coverage criterion C, a test set T satisfies C if and only if for every test requirement tr in TR, at least one test t in T exists such that t satisfies tr. 4

5
Coverage Level Given a set of test requirements TR and a test set T, the coverage level is simply the ratio of the number of test requirements satisfied by T to the size of TR. 5

6
Node Coverage (Formal Definition): For each node n ∈ reach G (N 0 ), TR contains the predicate “visit n.” Node Coverage (NC): TR contains each reachable node in G. Structural Coverage Criteria -I Node Coverage (NC) (Standard Definition) Test set T satisfies node coverage on graph G if and only if for every syntactically reachable node n in N, there is some path p in path(T) such that p visits n. TR = { 0, 1, 2 } path(t 1 ) = [0, 1, 2] T 1 ={t 1 } T 1 satisfies node coverage on the graph

7
Structural Coverage Criteria - II Edge coverage is slightly stronger than node coverage Edge Coverage (EC) : TR contains each reachable path of length up to 1, inclusive, in G. The “length up to 1” allows for graphs with one node and no edges Edge Coverage : TR = { (0,1), (0, 2), (1, 2) } path (t 1 ) = [ 0,1,2] path (t 2 ) = [ 0, 2 ] T 2 ={t 1, t 2 } Test Paths = [ 0, 1, 2 ] [ 0, 2 ] T 2 satisfies edge coverage on the graph

8
Paths of Length 1 and A graph with only one node will not have any edges It may be boring, but formally, Edge Coverage needs to require Node Coverage on this graph Edge Coverage needs to require Node Coverage on this graph Otherwise, Edge Coverage will not subsume Node Coverage So we define “length up to 1” instead of simply “length 1” We have the same issue with graphs that only have one edge for Edge Pair Coverage … 1 0

9
Structural Coverage Example Node Coverage TR = { 0, 1, 2, 3, 4, 5, 6 } Test Paths: [ 0, 1, 2, 3, 6 ] [ 0, 1, 2, 4, 5, 4, 6 ] Edge Coverage TR = { (0,1), (0,2), (1,2), (2,3), (2,4), (3,6), (4,5), (4,6), (5,4) } Test Paths: [ 0, 1, 2, 3, 6 ] [ 0, 2, 4, 5, 4, 6 ] path (t 1 )= [ 0, 1, 2, 3, 6 ] path (t 2 )=[ 0, 2, 4, 5, 4, 6 ] T={t 1, t 2 }

10
Structural Coverage Criteria – III Covering Multiple Edges Edge-pair coverage requires pairs of edges, or subpaths of length 2 Edge-Pair Coverage (EPC): TR contains each reachable path of length up to 2, inclusive, in G. The “length up to 2” is used to include graphs that have less than 2 edges The logical extension is to require all paths … 10

11
Edge-Pair Coverage Test Paths: [ 0, 1, 2, 3, 6 ] [ 0, 1, 2, 4, 6 ] [ 0, 2, 3, 6 ] [ 0, 2, 4, 5, 4, 5, 4, 6 ] TR = { [0,1,2], [0,2,3], [0,2,4], [1,2,3], [1,2,4], [2,3,6], [2,4,5], [2,4,6], [4,5,4], [5,4,5], [5,4,6] } path (t 1 )= [ 0, 1, 2, 3, 6 ] path (t 2 )= [ 0, 1, 2, 4, 6 ] path (t 3 )=[ 0, 2, 3, 6 ] path (t 4 )= [ 0, 2, 4, 5, 4, 5, 4, 6 ] T={t 1, t 2, t 3, t 4 }

12
Complete Path Coverage Complete Path Coverage (CPC) : TR contains all paths in G. This is impossible if the graph has a loop, so a weak compromise is to make the tester decide which paths Test Paths: [ 0, 1, 2, 3, 6 ] [ 0, 1, 2, 4, 6 ] [ 0, 1, 2, 4, 5, 4, 6 ] [ 0, 1, 2, 4, 5, 4, 5, 4, 6 ] [ 0, 1, 2, 4, 5, 4, 5, 4, 5, 4, 6 ] …

13
Simple Path : A path from node n i to n j is simple if no node appears more than once, except possibly the first and last nodes are the same No internal loops Includes all other subpaths A loop is a simple path Simple Paths : [ 0, 1, 3, 0 ], [ 0, 2, 3, 0], [ 1, 3, 0, 1 ], [ 2, 3, 0, 2 ], [ 3, 0, 1, 3 ], [ 3, 0, 2, 3 ], [ 1, 3, 0, 2 ], [ 2, 3, 0, 1 ], [ 0, 1, 3 ],[ 0, 2, 3 ],[ 1, 3, 0 ],[ 2, 3, 0 ],[ 3, 0, 1], [3, 0, 2], [ 0, 1], [ 0, 2 ], [ 1, 3], [ 2, 3], [ 3, 0], [0], [1], [2], [3] Simple Paths

14
Prime Paths and Prime Path Coverage Prime path (PP) gives strong coverage of loops without requiring an infinite number of paths In prime path coverage, tests must tour each prime path in the graph G. Prime path coverage requires touring all subpaths of length 0 (all nodes), of length 1 (all edges), length 2, 3, etc. Thus it subsumes node coverage, edge coverage and edge-pair coverage In prime path coverage, tests must tour each prime path in the graph G. 14

15
Prime Paths Prime Paths : [ 0, 1, 3, 0 ], [ 0, 2, 3, 0], [ 1, 3, 0, 1 ], [ 2, 3, 0, 2 ], [ 3, 0, 1, 3 ], [ 3, 0, 2, 3 ], [ 1, 3, 0, 2 ], [ 2, 3, 0, 1 ] Prime paths are maximal length simple paths

16
Another Example: Simple Paths Len 0 [0] [1] [2] [3] [4] [5] [6] ! Len 1 [0, 1] [0, 2] [1, 2] [2, 3] [2, 4] [3, 6] ! [4, 6] ! [4, 5] [5, 4] Len 2 [0, 1, 2] [0, 2, 3] [0, 2, 4] [1, 2, 3] [1, 2, 4] [2, 3, 6] ! [2, 4, 6] ! [2, 4, 5] ! [4, 5, 4] * [5, 4, 6] ! [5, 4, 5] * ! means path terminates * means path cycles Len 3 [0, 1, 2, 3] [0, 1, 2, 4] [0, 2, 3, 6] ! [0, 2, 4, 6] ! [0, 2, 4, 5] ! [1, 2, 3, 6] ! [1, 2, 4, 5] ! [1, 2, 4, 6] Len 4 [0, 1, 2, 3, 6] ! [0, 1, 2, 4, 6] ! [0, 1, 2, 4, 5] !

17
Control Flow Graphs : The if Statement 17 if (x < y) { y = 0; x = x + 1; } else { x = y; } x >= yx < y x = y y = 0 x = x + 1 if (x < y) { y = 0; x = x + 1; } x >= y x < y y = 0 x = x + 1

18
CFG : The if-Return Statement 18 if (x < y) { return; } print (x); return; x >= y x < y return print (x) return

19
Control Flow Graphs : while and for Loops 19 x = 0; while (x < y) { y = f (x, y); x = x + 1; } 1 x = 0 x >= yx < y x >= yx < y 43 y =f(x,y) x = x for (x = 0; x < y; x++) { y = f (x, y); } 2 35 x >= yx < y y = f (x, y) 4 1 x = x + 1

20
Control Flow Graphs : do Loop, break and continue 20 x = 0; do { y = f (x, y); x = x + 1; } while (x < y); println (y) 1 x = 0 2 x >= y x < y y = f (x, y) x = x+1 3 x = 0; while (x < y) { y = f (x, y); if (y == 0) { break; } else if y < 0) { y = y*2; continue; } x = x + 1; } print (y); 1 x = 0 83 x = x + 1 break y < y =f(x,y) y == 0 y = y*2 continue

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google