George Mason University

Slides:



Advertisements
Similar presentations
1 Software Unit Test Coverage And Test Adequacy Hong Zhu, Patrick A. V. Hall, John H.R. May Presented By: Arpita Gandhi.
Advertisements

DATAFLOW TESTING DONE BY A.PRIYA, 08CSEE17, II- M.s.c [C.S].
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).
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
COVERAGE CRITERIA FOR TESTING 1. ill-defined terms in Testing  complete testing  exhaustive testing  full coverage Are poorly defined terms because.
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.
Comparison of Unit-Level Automated Test Generation Tools Shuang Wang Co-authored with Jeff Offutt April 4,
Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Presented By Dr. Shazzad Hosain Asst. Prof., EECS, NSU
Overview Graph Coverage Criteria ( Introduction to Software Testing Chapter 2.1, 2.2) Paul Ammann & Jeff Offutt.
Coverage Criteria for Testing of Object Interactions in Sequence Diagrams Atanas (Nasko) Rountev Scott Kagan Jason Sawin Ohio State University.
Of 18 Is Bytecode Instrumentation as Good as Source Instrumentation? An Empirical Study with Industrial Tools Nan Li, Xin Meng, Jeff Offutt, and Lin Deng.
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
Software Testing and Maintenance Lecture 2.1 Overview Graph Coverage
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
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)
Introduction to Software Testing (2nd edition) Chapter 5 Criteria-Based Test Design Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Generating Automated Tests from Behavior Models
Paul Ammann & Jeff Offutt
ISP Coverage Criteria CS 4501 / 6501 Software Testing
Introduction to Software Testing Chapter 9.2 Program-based Grammars
Software Testing and Maintenance 1
Paul Ammann & Jeff Offutt
Graph Coverage Criteria CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
Input Space Partition Testing CS 4501 / 6501 Software Testing
Graph: Data Flow Criteria CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
Structural testing, Path Testing
Graph Coverage for Design Elements CS 4501 / 6501 Software Testing
White-Box Testing Techniques II
Paul Ammann & Jeff Offutt
It is great that we automate our tests, but why are they so bad?
Paul Ammann & Jeff Offutt
White-Box Testing Techniques II
Introduction to Software Testing Chapter 5.2 Program-based Grammars
Paul Ammann & Jeff Offutt
ISP Coverage Criteria CS 4501 / 6501 Software Testing
Graph Coverage for Design Elements CS 4501 / 6501 Software Testing
Graph: Data Flow Coverage Criteria 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
Graph Coverage Criteria CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
White-Box Testing Techniques II
Graph Coverage Criteria
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
An Analysis of OO Mutation Operators Jingyu Hu, Nan Li, and Jeff Offutt Presented by Nan Li 03/24/2011.
Software Testing and QA Theory and Practice (Chapter 5: Data Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Mutation Testing Faults are introduced into the program by creating many versions of the program called mutants. Each mutant contains a single fault. Test.
Presentation transcript:

George Mason University An Experimental Comparison of Four Unit Test Criteria: Mutation, Edge-Pair, All-uses and Prime Path Coverage 1 Presented by Nan Li George Mason University 5/3/2019

Overview Motivation Graph-based criteria/mutation criterion Tools 2 Motivation Graph-based criteria/mutation criterion Tools Experiment Analysis and discussion Threats to validity Conclusion 5/3/2019

Motivation Unit testing is increasingly becoming important 3 Unit testing is increasingly becoming important It’s difficult to decide which criterion should be used and when Previous comparisons have not included edge-pair and prime paths coverage 5/3/2019

(1) Graph-based coverage criteria – Edge Pair 4 Edge-pair coverage is based on control flow graphs Edge-pair coverage criterion : covers each reachable path of length up to 2, inclusive, in G Test Requirements: [0, 2, 3] [0, 2, 4] [1, 2, 3] [1, 2, 4] 1 2 3 4 5/3/2019

(2) Graph-based coverage criteria – Prime Paths 5 Simple path: A path from node ni to nj is simple if no node appears more than once, except possibly the first and last nodes are the same E.g. [1, 2, 3], [1, 2, 3, 2], [1, 2, 1] Prime path: A simple path that does not appear as a proper subpath of any other simple path E.g. [1, 2, 3], [1, 2, 3, 4] Prime path coverage criterion: contains each prime path in G 5/3/2019

(3) Graph-based coverage criteria – All-Uses 6 All-uses coverage is based on data flow graphs Definitions or defs: Nodes or edges where a variable is assigned a value Uses: nodes or edges where the value of a variable is accessed All-uses coverage criterion requires tests to tour at least one subpath from each definition to each reachable use 5/3/2019

Graph-based coverage criteria (cont.) 7 An example: i = x. length – 1 // return index of the last element in X that equals y def (0) = { x, y, i } use (0) = { x } // if y is not in X, return -1 use (1) = { i } public class findLast { public int findLast (int [] x, int y) { i >= 0 i < 0 for (int i = x.length-1; i >= 0; i--) use (2) = { x, y, i } { x[i] != y x[i] == y if (x[i] == y) i-- return i; def (3) = { i } use(3) = { i } use (5) = { i } } return -1; Edge-pair coverage: [0, 1, 2], [1, 2, 3]… Prime path coverage: [0, 1, 2, 5], [1, 2, 3, 1]… All-uses coverage: (0, 0, x),, (0, 2, x), (0, 2, y), (0, 3, i), (0, 5, i), (3, 3, i)… 1 4 2 3 5 5/3/2019

(4) Mutation coverage Mutation coverage is a syntax-based criterion 8 Mutation coverage is a syntax-based criterion Two steps to generate tests Create mutants (small changes) on the source code by applying mutation operators Generate tests by “killing” mutants 5/3/2019

Tools (Graph Coverage Web Application) 9 Graph coverage web application: http://cs.gmu.edu:8080/offutt/coverage/ Get test requirements and test paths for prime path coverage Require graph information: edges, initial nodes, and final nodes Get test paths for all-uses coverage Require data flow information: defs and uses 5/3/2019

Tools (muJava) muJava: Generate mutants Analyze mutants 10 muJava: Generate mutants Analyze mutants Run tests cases 5/3/2019

Experiment Goal 11 Goal: to compare the four coverage criteria based on effectiveness and efficiency Effectiveness : number of faults detected Efficiency: number of tests needed to satisfy the criteria 5/3/2019

Experiment (Variables and Subjects) 12 Independent variables: four test criteria used Dependent variables: number of tests and number of faults found Subjects: 29 fault-seeded Java programs Min Max Total Lines 26 618 2909 Classes 1 11 51 Methods 50 174 Faults 19 88 5/3/2019

Experiment (Faults) Seeded by the second author (Upsorn) 13 Seeded by the second author (Upsorn) To avoid possible interactions among the faults, each fault was seeded into a separate copy of the class Side effect: some faults are similar to mutants and others are exact mutants created by muJava 5/3/2019

Experiment (Test Set Values) 14 Goal: four sets of tests of each program overlapped as much as possible Four steps to generate test cases: generate test cases for edge-pair, prime path, all-uses, mutation coverage in order Requirements Infeasible Requirements Tests Edge-Pair 684 7 (1%) 344 All-Uses 453 62 (13.7%) 362 Prime Paths 849 175 (20.6%) 436 Mutation 2919 562 (19.3%) 269 5/3/2019

Experiment (Test Set Values cont.) Prime path: 436 Edge-pair: 344 Mutation: 269 All-uses: 362 5/3/2019

Experiment (Results) 16 5/3/2019

Experiment (Results cont.) 17 Number of faults Number of faults found Type of faults Edge-pair All-uses Prime Path Mutation muJava faults 9 5 Mutant-like faults 19 13 14 17 Non mutant-like faults 60 37 36 49 Sum 88 55 54 56 75 5/3/2019

Analysis and discussion (1) 18 Prime path coverage subsumes edge-pair coverage and all-uses coverage Prime path coverage only found one and two more faults than edge-pair and all-uses coverage 5/3/2019

Analysis and discussion (2) 19 Mutation coverage found more faults than prime path coverage Mutation coverage needed fewer test cases than prime path coverage Cost / benefit 5/3/2019

Analysis and discussion (2 cont.) 20 Number of test cases (cost) Number of faults found (benefit) Cost / benefit Edge-pair 344 55 6.3 All-uses 362 54 6.7 Prime path 436 56 7.8 Mutation 269 75 3.6 5/3/2019

Analysis of a specific fault 21 public static int lastZero (int[] x) { // if x==null throw NullPointerException else return index of the LAST 0 in x // Return -1 if 0 is not in x for (int i = 0; i < x.length; i++){ if (x[i] == 0) { return i; } return -1; Tests for mutation coverage: {0}, {2}, {1, 0}, {-1} The fault can have been found by {0, 1, 0} 5/3/2019

Threats to validity 22 External validity: not sure the subjects are representative Internal validity: faults were seeded by hand and the specific tools used Construct validity: faults were generated by only one person and test cases were generated manually 5/3/2019

Conclusions 23 As expected, mutation testing can find more faults than other criteria Contrary to what we expected, the experiment found mutation to be the most efficient 5/3/2019

Contact 24 Nan Li nli1@gmu.edu http://cs.gmu.edu/~nli1 5/3/2019