Graph Coverage Criteria Structural Coverage Criteria : Defined on a graph just in terms of nodes and edges Data Flow Coverage Criteria : Requires a graph.

Slides:



Advertisements
Similar presentations
Coverage Criteria Drawn mostly from Ammann&Offutt and Pezze&Yooung.
Advertisements

Data Flow Coverage. Reading assignment L. A. Clarke, A. Podgurski, D. J. Richardson and Steven J. Zeil, "A Formal Evaluation of Data Flow Path Selection.
Paul Ammann & Jeff Offutt
Graph Coverage (2).
CITS5501 Software Quality and Testing Logic and Path Coverage From Introduction to Software Testing, 2 nd ed, Ammann & Offutt.
Introduction to Software Testing Chapter 2.1, 2.2 Overview Graph Coverage Criteria Paul Ammann & Jeff Offutt
Lecture 2 White-box Testing and Structural Coverage.
COVERAGE CRITERIA FOR TESTING 1. ill-defined terms in Testing  complete testing  exhaustive testing  full coverage Are poorly defined terms because.
Introduction to Software Testing (2nd edition) Chapter 5 Criteria-Based Test Design Paul Ammann & Jeff Offutt
The Application of Graph Criteria: Source Code  It is usually defined with the control flow graph (CFG)  Node coverage is used to execute every statement.
Software Testing Mistake in coding is called error ,
Introduction to Software Testing Chapter 1 Introduction Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
White-Box Testing Techniques II Originals prepared by Stephen M. Thebaut, Ph.D. University of Florida Dataflow Testing.
Overview Graph Coverage Criteria ( Introduction to Software Testing Chapter 2.1, 2.2) Paul Ammann & Jeff Offutt.
Coverage Literature of software testing is primarily concerned with various notions of coverage Four basic kinds of coverage: Graph coverage Logic coverage.
Software Testing and Maintenance Lecture 4 Graph Coverage for Design Element Paul Ammann & Jeff Offutt Instructor: Hossein Momeni Mazandaran.
1 Software Testing. 2 Path Testing 3 Structural Testing Also known as glass box, structural, clear box and white box testing. A software testing technique.
Introduction to Software Testing Chapters 1-5 Coverage Summary Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt
Software Verification Graph Model. 2 Graph Coverage Four Structures for Modeling Software Graphs Logic Input Space Syntax Use cases Specs Design Source.
Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt.
Software Testing and Maintenance Lecture 2.1 Overview Graph Coverage
Overview Structural Testing Introduction – General Concepts
1 Graph Coverage (3). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section 2.2 ◦ Section
1. Black Box Testing  Black box testing is also called functional testing  Black box testing ignores the internal mechanism of a system or component.
Control Flow Graphs : The if Statement 1 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;
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
Paul Ammann & Jeff Offutt
Data Flow Coverage Criteria
White-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 7.
Software Testing and Maintenance Lecture 3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt Instructor: Hossein Momeni Mazandaran.
Data Flow Testing. Introduction to Software Testing (Ch 2) © Ammann & Offutt 2 Definition of a Graph A set N of nodes, N is not empty A set N 0 of initial.
White-Box Testing Statement coverage Branch coverage Path coverage
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Software Testing and Maintenance 1
Paul Ammann & Jeff Offutt
Graph Coverage Criteria CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
Graph: Data Flow Criteria CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
Path testing Path testing is a “design structural testing” in that it is based on detailed design & the source code of the program to be tested. The.
White-Box Testing Techniques II
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
White-Box Testing Techniques II
Paul Ammann & Jeff Offutt
Graph: Data Flow Coverage Criteria CS 4501 / 6501 Software Testing
Graph Coverage for Source Code
Paul Ammann & Jeff Offutt
Graph Coverage Criteria CS 4501 / 6501 Software Testing
Activity: Prime Path Coverage CS 4501 / 6501 Software Testing
White-Box Testing Techniques I
Graph Coverage Criteria
Graph Coverage Criteria CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
White-Box Testing Techniques II
Graph Coverage Criteria
Paul Ammann & Jeff Offutt
George Mason University
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Graph-based Test Coverage (A&O Ch. 1, 2. 1 – 2. 3) (2nd Ed: 2,3,5,7
Presentation transcript:

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

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

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

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

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

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

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

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

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 }

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

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 }

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 ] …

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

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

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

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] !

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

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

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

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