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.

Slides:



Advertisements
Similar presentations
Lecture 07 – Iterating through a list of numbers.
Advertisements

DATAFLOW TESTING DONE BY A.PRIYA, 08CSEE17, II- M.s.c [C.S].
A Survey of Program Slicing Techniques A Survey of Program Slicing Techniques Sections 3.1,3.6 Swathy Shankar
Whitebox Testing Fra: CS Fall Whitebox Testing AKA Structural, Basis Path Test Normally used at unit level Assumes errors at unit level are.
Systems V & V, Quality and Standards
Graph Coverage for Design Elements 1.  Use of data abstraction and object oriented software has increased importance on modularity and reuse.  Therefore.
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.
Graph Coverage Criteria Structural Coverage Criteria : Defined on a graph just in terms of nodes and edges Data Flow Coverage Criteria : Requires a graph.
Introduction to Software Testing Chapter 2.1, 2.2 Overview Graph Coverage Criteria Paul Ammann & Jeff Offutt
Software Testing Sudipto Ghosh CS 406 Fall 99 November 16, 1999.
Software Testing and Quality Assurance
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
Introduction to Software Testing Chapter 2.4 Graph Coverage for Design Elements 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.
Software Testing and Maintenance Lecture 4 Graph Coverage for Design Element Paul Ammann & Jeff Offutt Instructor: Hossein Momeni Mazandaran.
1 Graph Coverage (4). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section
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 (2nd edition) Chapter 7.4 Graph Coverage for Design Elements 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
Graph Coverage for Design Elements 1.  Use of data abstraction and object oriented software has increased importance on modularity and reuse.  Therefore.
1 Graph Coverage (3). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section 2.2 ◦ Section
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
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.
Chapter 2 : Graph Coverage (part 2)
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
Program Slicing Baishakhi Ray University of Virginia
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
White-Box Testing Techniques II
Paul Ammann & Jeff Offutt
Graph Coverage for Design Elements CS 4501 / 6501 Software Testing
Sudipto Ghosh CS 406 Fall 99 November 16, 1999
Graph Coverage for Source Code
Paul Ammann & Jeff Offutt
Graph Coverage Criteria CS 4501 / 6501 Software Testing
Graph Coverage Criteria
White-Box Testing Techniques II
Graph Coverage Criteria
Paul Ammann & Jeff Offutt
George Mason University
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Presentation transcript:

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  Edge coverage is used to execute every branch  Loops are used to execute looping structures such as for loops, while loops, etc.  Data flow coverage is the extended form of control flow graph (CFG) with defs and uses  defs are statements that assign values to variables  uses are statements that use variables

Tests with Data Flow Criteria  Data flow criteria require tests that tour subpaths from specific definitions of variables to specific uses  Nodes where a variable is assigned a value are called definitions (or defs)  Nodes where the value of a variable is accessed are called uses.

3 Data Flow Coverage for Source  def : A location where a value is stored into memory  x appears on the left side of an assignment ( x = 44 ;  x is an actual parameter in a call and the method changes its value  x is a formal parameter of a method (implicit def when method starts)  x is an input to a program  use : A location where variable’s value is accessed  x appears on the right side of an assignment  x appears in a conditional test  x is an actual parameter to a method  x is an output of the program  x is an output of a method in a return statement  If a def and a use appear on the same node, then it is only a DU-pair if the def occurs after the use and the node is in a loop

 A definition d for a variable x reaches a use u if there is a path from d to u that has no other definitions of x (def-clear).  The all-uses (AU) criterion requires tests to tour at least one subpath from each definition to each reachable use. // EXAMPLE: return index of the last element in x that equals y. // if y is not in x, return -1. public int findLast (int []x, int y) { for (int i = x.length-1; i>=0; i--) { if (x[i] == y) return i; } return -1;

Annotated Control Graph  Nodes 4 and 6 are final nodes, corresponding to the return statements.  Node 2 is introduced to capture the for loop; it has no executable statements.  DU (def-use) pairs are shown as a variable name followed by the def node, then the use node. use(3)= def (5) = { i } use (5) = { i } Def -Use Pairs = { (1, 1,x), (1,3,x), (1,3,y), (1, 2,i), (1, 3,i), (1,5,i), (1,6,i), (5, 2,i), (5, 3,i), ( 5, 6,i), (5, 5,i)}

public static void computeStats (int [ ] numbers) { int length = numbers.length; double med, var, sd, mean, sum, varsum; sum = 0; for (int i = 0; i < length; i++) { sum += numbers [ i ]; } med = numbers [ length / 2]; mean = sum / (double) length; varsum = 0; for (int i = 0; i < length; i++) { varsum = varsum + ((numbers [ I ] - mean) * (numbers [ I ] - mean)); } var = varsum / ( length ); sd = Math.sqrt ( var ); System.out.println ("length: " + length); System.out.println ("mean: " + mean); System.out.println ("median: " + med); System.out.println ("variance: " + var); System.out.println ( "standard deviation: " + sd); } 6 i = i >= length i < length i++

Edge Coverage TR = {[ 1, 2 ],[ 2, 3 ],[ 3, 4 ], [ 3, 5 ], [ 4, 3 ], [ 5, 6 ], [ 6, 7 ], [ 6, 8 ],[ 7, 6 ]} Test Path, 3, 4, 3, 5, 6, 7, 6, 8 ] [ 1, 2, 3,4, 3, 5, 6, 7, 6, 8] ]

Edge-Pair Coverage TR={ [ 1, 2, 3 ], [ 2, 3, 4 ], [ 2, 3, 5 ], [ 3, 4, 3 ], [ 3, 5, 6 ], [ 4, 3, 5 ],[ 5, 6, 7 ],[ 5, 6, 8 ], [ 6, 7, 6 ], [ 7, 6, 8 ], [ 4, 3, 4 ], [ 7, 6, 7 ]} Test Paths i.[ 1, 2, 3, 4, 3, 5, 6, 7, 6, 8 ] ii. [ 1, 2, 3, 5, 6, 8 ] iii. [ 1, 2, 3, 4, 3, 4, 3, 5, 6, 7, 6, 7, 6, 8 ] Test Requirements Toured i.[ 1, 2, 3 ], [ 2, 3, 4 ], [ 3, 4, 3 ], [ 3, 5, 6 ], [ 4, 3, 5 ], [ 5, 6, 7], [ 6, 7, 6 ], [ 7, 6, 8 ] ii. [ 1, 2, 3 ], [ 2, 3, 5 ], [ 3, 5, 6 ], [ 5, 6, 8 ] iii. [ 1, 2, 3 ], [ 2, 3, 4 ], [ 3, 4, 3 ], [ 3, 5, 6 ], [ 4, 3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