Debugging and Injecting Course Software Testing & Verification 2014/15 Wishnu Prasetya The debugging part uses Andreas Zeller’s slides. This is extra.

Slides:



Advertisements
Similar presentations
Reconciling OO and Haskell-Style Overloading Mark Shields Simon Peyton Jones Microsoft Research Cambridge
Advertisements

Chapter Three: Closure Properties for Regular Languages
Delta Debugging and Model Checkers for fault localization
Random Testing Tor Stålhane Jonas G. Brustad. What is random testing The principle of random testing is simple and can be described as follows: 1.For.
Model Based Testing Course Software Testing & Verification 2013/14 Wishnu Prasetya.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 52 Database Systems I Relational Algebra.
1 Software Testing and Quality Assurance Lecture 9 - Software Testing Techniques.
CS590Z Delta Debugging Xiangyu Zhang (slides adapted from Tevfik Bultan’s )
Well-behaved objects 4.0 Testing. 2 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main concepts to.
Catriel Beeri Pls/Winter 2004/5 type reconstruction 1 Type Reconstruction & Parametric Polymorphism  Introduction  Unification and type reconstruction.
(c) 2007 Mauro Pezzè & Michal Young Ch 16, slide 1 Fault-Based Testing.
Terms and Rules Professor Evan Korth New York University (All rights reserved)
272: Software Engineering Fall 2008 Instructor: Tevfik Bultan Lecture 17: Automated Debugging.
Introduction to Software Testing Chapter 9.1 Syntax-based Testing Paul Ammann & Jeff Offutt
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
CHAPTER 10 Recursion. 2 Recursive Thinking Recursion is a programming technique in which a method can call itself to solve a problem A recursive definition.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Introduction to Software Testing Chapter 5.2 Program-based Grammars Paul Ammann & Jeff Offutt
Inheritance in C++ CS-1030 Dr. Mark L. Hornick.
Software Testing and Validation SWE 434
CMSC 345 Fall 2000 Unit Testing. The testing process.
© SERG Dependable Software Systems (Mutation) Dependable Software Systems Topics in Mutation Testing and Program Perturbation Material drawn from [Offutt.
Coverage – “Systematic” Testing Chapter 20. Dividing the input space for failure search Testing requires selecting inputs to try on the program, but how.
Coverage Literature of software testing is primarily concerned with various notions of coverage Four basic kinds of coverage: Graph coverage Logic coverage.
Foundations of Software Testing Chapter 5: Test Selection, Minimization, and Prioritization for Regression Testing Last update: September 3, 2007 These.
Bug Localization with Machine Learning Techniques Wujie Zheng
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Software testing techniques Software testing techniques Mutation testing Presentation on the seminar Kaunas University of Technology.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
637 – Introduction (Ch 1) Introduction to Software Testing Chapter 1 Jeff Offutt Information & Software Engineering SWE 437 Software Testing
Introduction to Software Testing Chapter 9.3 Integration and Object- Oriented Testing Paul Ammann & Jeff Offutt
Wishnu Prasetya WLP for Automated Testing.
Syntax-Based Testing Mingzhe Du Hongying Du Dharani Chintapatla.
(1) Unit Testing and Test Planning CS2110: SW Development Methods These slides design for use in lab. They supplement more complete slides used in lecture.
Software Testing Integration and Object-Oriented Testing.
Automated Patch Generation Adapted from Tevfik Bultan’s Lecture.
Introduction to Software Testing Chapter 5.3 Integration and Object-Oriented Testing Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 5.3 Integration and Object-Oriented Testing Paul Ammann & Jeff Offutt
Software Testing Part II March, Fault-based Testing Methodology (white-box) 2 Mutation Testing.
Software Testing Syntax-based Testing. Syntax Coverage Four Structures for Modeling Software Graphs Logic Input Space Syntax Use cases Specs Design Source.
Function Definition by Cases and Recursion Lecture 2, Programmeringsteknik del A.
Introduction to Software Testing Chapter 9.2 Program-based Grammars Paul Ammann & Jeff Offutt
OOP Basics Classes & Methods (c) IDMS/SQL News
Mutation Testing Breaking the application to test it.
HW7: Due Dec 5th 23:59 1.Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw.
Simplifying and Isolating Failure-Inducing Input Andreas Zeller and Ralf Hildebrandt IEEE Transactions on Software Engineering (TSE) 2002.
Foundations of Software Testing Chapter 5: Test Selection, Minimization, and Prioritization for Regression Testing Last update: September 3, 2007 These.
MUTACINIS TESTAVIMAS Benediktas Knispelis, IFM-2/2 Mutation testing.
Mutation Testing Laraib Zahid & Mariam Arshad. What is Mutation Testing?  Fault-based Testing: directed towards “typical” faults that could occur in.
Wishnu Prasetya Software Testing URL:
Lecture 10 – Polymorphism Nancy Harris with additional slides Professor Adams from Lewis & Bernstein.
Software Testing and Quality Assurance Syntax-Based Testing (2) 1.
Introduction to Software Testing (2nd edition) Chapter 5 Criteria-Based Test Design Paul Ammann & Jeff Offutt
Course Software Testing & Verification 2016/17 Wishnu Prasetya
Introduction to Software Testing Chapter 9.2 Program-based Grammars
Mutation Testing Moonzoo Kim School of Computing KAIST
Mutation testing Julius Purvinis IFM-0/2.
Aditya P. Mathur Purdue University
Syntax-based Testing CS 4501 / 6501 Software Testing
Introduction to Software Testing Chapter 5.1 Syntax-based Testing
Introduction to Software Testing Chapter 9.2 Program-based Grammars
Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 5.2 Program-based Grammars
PPT1: How failures come to be
Software Testing Syntax-based Testing.
Introduction to Software Testing Chapter 5.1 Syntax-based Testing
Mutation Testing Moonzoo Kim School of Computing KAIST
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:

Debugging and Injecting Course Software Testing & Verification 2014/15 Wishnu Prasetya The debugging part uses Andreas Zeller’s slides. This is extra. The ‘”injecting” part is about mutation testing; this is discussed in Ch 5 of the book.

Debugging Suppose we observe a program “fails”. Debugging: find the root cause of the failure (the error made in the program). Then we can fix the program. Very time consuming, especially at the system-level. How about automation? 2

Simplification Debugging = find an item of some property, in a given search space. It can at least be made easier if the “search space” is shrunk (simplification). Can we simplify systematically? E.g. binary search comes to mind.... 3

Let’s First Re-express the Problem More abstractly, so that we can later apply the solution to different concrete situations. A test-case is abstractly represented by a configuration c, which is made up of “units”  1,  2,...  n organized in some structure (e.g. a list of units, or a tree of units). For simplicity, here we assume c is a set of units. So: c = {  1,  2,...  n } 4

Configurations test(c) executes the configuration c, resulting either (pass),  (fail), or ? (the configuration is actually invalid). two configurations can be compared to decide which one is “simpler”. Since we said a configuration is a set, we use c 1  c 2. Minimalization: if c  is the initial failing configuration, (test(c  )=  ), find the smallest subset c of c  such that test(c)= . Expensive... 5

Simplification Simplification: find a “relevant” configuration. If c  is the initial failing configuration (test(c)=  ), a subset c of c  is relevant if test(c)=  and if removing any unit from c causes  to disappear. That is:  :  c : test(c /{  })   Note that a relevant configuration does not have to be minimal. 6

Binary Strategy Let c  be the initial failingconfiguration. A binary simplify(c  ) is defined as follows: 1.simplify(c) = 2. if |c|= 1 then return c // minimal 3. split c to c 1  c 2 4. if test(c 1 )=  then return simplify(c 1 ) 5. if test(c 2 )=  then return simplify(c 2 ) 6. /* 4 and 5 give or ? */ return c Yield a simpler confg, but not necessarily relevant. 7

Delta Debugging-min Algorithm simplify(c) = ddmin(c,2) defined below 1.ddmin(c,N) = // N is split granularity 2. if |c|= 1 then return c 3. split c into c 1 ...  c N 4. if for some k, test(c/c k )=  then return ddmin ( c/c k, max(N-1,2) ) 5. else if N<|c| // increase granularity then return ddmin( c, min(2N, |c|) ) 6. else return c 8

Example 9 orig  ddmin([1..8], 2)? ? ddmin([1..8], 4)  ddmin([1,2,3,4,7,8], 3)  ddmin([1,2,7,8], 2)? ? ddmin([1,2,7,8], 4)  ddmin([2,7,8], 3)? ? ? return with c = [2,7,8]

Complexity ddmin Worst case, invoking test this number of times: ( |c  | |c  | ) / 2 If – there is only one failure-inducing unit in the initial configuration, and – all configurations that include the unit would fail then the number of tests is: 2 log(|c  |). 10

Localizing Let c  be the initial failing configuration. Find subsets s  f  c  such that: – s succeeds – f fails – their difference  = f/s is “minimal”. That is, for any   : test(s  {  })  test(f / {  })   If|  |=1, it contains the problem unit. If |  | >1, it may contain units whose addition or removal lead to an invalid configuration. 11

Idea Adapt ddmin to operate on a pair input configurations: s and f Split  = f/s to  1 ...  N Check the outcome of: – test(s   k ) – test(f /  k ) Well, now we have more outcome combinations... 12

Possible outcomes of tests  test(s   k )f := s   k s := s   k test(f /  k )f := f /  k s := f /  k 13 Else, (so, for any partition  k of  the outcome is none of the above), increase split granularity. If for for some partition  k of  the outcome is one of these:

The dd Algorithm localize(c) = dd( ,c,2) defined below 1.dd(s,f,N) = 2.  := f/s 3. if |  |= 1 then return (s,f) 4. split  into  1 ...   N 5. if for some k, test(s   k )=  then return dd (s, s   k,2) 6. if for some k, test(s   k )= then return dd (s   k,f, max(N-1,2) ) 7. if for some k, test(f/  k )=  then return dd ( s, f/  k, max(N-1,2) ) 8. if for some k, test(f /  k )= then return dd (f/  k,f,2 ) 9. if N<|  | // increase granularity then return dd( f,d, min(2N, |  |) ) 10. else return (s,f) 14

Mutation Test 15

Mutants Mutation: changing a valid artifact, usually by a minimalistic amount, to produce an invalid version of it. The result: mutant (Def 5.47, different formulation) Application: – negative testing, to produce invalid inputs. – seeding errors in a program To systematically generate mutants, we introduce mutation operators (Def 5.46) 16

Example 17 NLpostcode  Area Space Street Area  FirstDigit Digit Digit Digit Street  Letter Letter FirstDigit  1 | 2... Digit  0 | 1 | 2... Letter  a | b | c... | A | B | C... Space   | “ “ Space NLpostcode  Street Area Area  FirstDigit Digit Digit Area  FirstDigit Digit Digit Digit Digit If an input is described by a BNF grammar, we can systematically mutate the grammar to produce mutants for negative tests.

Some coverage concepts for grammar- based mutants generation To define how much mutants to generate. Imagine a set of mutation operators can be applied on BNF production rules. (C 5.33) Mutation Operator Coverage (MOC) : for every mutop , TR contains 1x mutant produced by . (C5.34) Mutation Production Cov: for every production rule r and every mutop  applicable to r, TR contains one mutant produced by  (r). 18

Systematic error seeding (5.2) Let’s mutate a program to “simulate” programming mistakes, resulting syntactically valid mutants, but containing mistakes. We can use this to test your tests, to see how “effective” they are  called mutation test. Considered to be very strong. Tools: – Pitest, Major for Java – NinjaTurtles (beta) for C# – MuCheck for Haskell 19

Example 20 (mutations generated by the tool Mothra)

Typical Tooling Setup 21 Program PMutants of P Fix P construct test set T run T on P run T on mutants a test-case fails not enough mutants percentage killed This is a simpler variation of the scheme in Fig. 5.2

Killing a mutant (D 5.50) Let P be the original program. A test t of P weakly kills a mutant P’ of P if executing t on them results in different (internal) states, immediately after the mutation spot. (D 5.50) The test t strongly kills P’ if executing it on P and P’ produces different outcomes. 22 P(x) { if (x<0) { y=x ; return x } y=1 ; return 0 } P(x) { if (x  0) { y=x ; return x } y=1 ; return 0 } test2() { r = P(0) ; assert (return==0) } test1() { r = P(0) ; assert (y==1) } test3() { r = P(2) ; assert (return==2) }

Mutation-based coverage criteria (C5.32) Given a set M of mutants, the TR is simply M: you have to “kill” every mutant in M. OA remark that in practice strong vs weak do not make much difference  careful, this depends on the oracles used. In particular if you use partial oracles, e.g. in property-based testing, they mat actually make much difference. The strength depends on the choice of mutops. See and Preferably you want mutops that simulate realistic errors. Also, try to minimize the mutops, or else mutation testing becomes too expensive. 23

Mutation operators (D5.51) Given a set O 2 of mutation operators; a subset O 1 is effective if test-cases designed specifically to kill mutants produced by O 1 will (very likely) also kill mutants from O 2 /O 1. The smallest set of effective mutops? Hard to know, and very situation specific. Still, there have been plenty of research to see if there are some general patterns. For mutations over imperative constructs, see Mutations on OO aspects, see

Mutops on imperative constructs (5.2.2) ABS (Absolute Value Insertion) Modify each arithmetic (sub)expression by using functions abs(), negAbs(), and failOnZero(). AOR (Arithmetic Operator Replacement) Replace each occurrence of arithmetic operators +, -,*, /, % by each other; and in addition, by leftOp, and rightOp. SVR (Scalar Variable Replacement) Replace each variable reference by another (type compatible and in-scope) variable. BSR (Bomb Statement Replacement) Replace each statement by Bomb(). More... see book. 25

OO-related Mutops additionally lists 20 mutops targeting typical OO aspects, e.g. : – Inheritance: method overriding, variables shadowing, constructors overriding works differently – Polymorphism – Use of static members I will only show some, as examples 26

OO-related Mutops 27 ANC – Argument Number Change Point3D p; p.set (1, 2, 3);  p.set (2, 3); Point3D void set (int x, int y, int z); void set (int x, int y); AOC – Argument Order Change Point3D p ; p.set (1, 2, ‘t’) ;  p.set (‘t’, 1, 2) ; Point3D void set (int x, int y, char c); void set (char a, int x, int y);

OO-related Mutops OMD (Overriding Method Deletion): delete an overriding method. OMM (Overridden Method Moving): move a call to a super.method to the first or last position, or up and down one statement. 28 m() { x ++ ; y = y/x ; super.m() ; }

OO-related Mutops 29 HVI – Hiding Variable Insertion colorpoint  1 int x;  2 int y; point int x; int y; HVD – Hiding Variable Deletion point int x; int y; colorpoint int x;  1 // int x; int y;  2 // int y;

OO-related Mutops 30 ATC – Actual Type Change Point p ; p = new Point();  p = new Point3D(); DTC – Declared Type Change Point p ;  Point3D p ; p = PointFactory(); Point Point3D