MUTACINIS TESTAVIMAS Benediktas Knispelis, IFM-2/2 Mutation testing.

Slides:



Advertisements
Similar presentations
1 Automating the Generation of Mutation Tests Mike Papadakis and Nicos Malevris Department of Informatics Athens University of Economics and Business.
Advertisements

David Pryor. Mutation-Based Testing Same basic goal as Code Coverage Evaluate the tests Determine how much code exercised Mutation testing goes beyond.
MUTATION TESTING. Mutation testing is a technique that focuses on measuring the adequacy (quality) of test data (or test cases). Modify a program by introducing.
Written by: Dr. JJ Shepherd
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
An Analysis and Survey of the Development of Mutation Testing by Yue Jia and Mark Harmon A Quick Summary For SWE6673.
Mutation Testing Presented by Sharath Kumar Garlapati Vinesh Thummala.
Pedro Reales Mateo University of Castilla-La Mancha Alarcos Research Group University of Castilla-La Mancha Macario Polo Usaola University of Castilla-La.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
1 Software Testing and Quality Assurance Lecture 9 - Software Testing Techniques.
The Programming Discipline Professor Stephen K. Kwan 2010 Things you need to know (learn) for developing large computer programs.
1 Conditionals In many cases we want our program to make a decision about whether a piece of code should be executed or not, based on the truth of a condition.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Chapter 2 Control. "The Practice of Computing Using Python", Punch & Enbody, Copyright © 2013 Pearson Education, Inc. Repetition, quick overview.
Introduction to Software Testing Chapter 5.2 Program-based Grammars Paul Ammann & Jeff Offutt
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Software Testing and Validation SWE 434
Kyle Mundt February 3,  Richard Lipton, 1971  A way of testing your tests  Alter your code in various ways  Check to see if tests fail on altered.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
© 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.
Unit Testing -Ranjit Shewale Contents  Scope  Owner  Approach  Conventional approach  Object oriented approach  Tips for the.
What is Mutation Testing ? The premise in mutation testing is that small changes are made in a module and then the original and mutant modules are compared.
By Ian Jackman Davit Stepanyan.  User executed untested code.  The order in which statements were meant to be executed are different than the order.
Software testing techniques Software testing techniques Mutation testing Presentation on the seminar Kaunas University of Technology.
Mr. Dave Clausen1 La Cañada High School Chapter 6: Repetition Statements.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
White-box Testing.
Syntax-Based Testing Mingzhe Du Hongying Du Dharani Chintapatla.
Chapter 5: Structured Programming
Java Basics Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Mutation Testing G. Rothermel. Fault-Based Testing White-box and black-box testing techniques use coverage of code or requirements as a “proxy” for designing.
Exceptions Chapter 16 This chapter explains: What as exception is Why they are useful Java exception facilities.
Software Testing Part II March, Fault-based Testing Methodology (white-box) 2 Mutation Testing.
Introduction to Software Testing Chapter 9.2 Program-based Grammars Paul Ammann & Jeff Offutt
Structured Programming The Basics. Control structures They control the order of execution What order statements will be done in, or whether they will.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
Condition Testing. Condition testing is a test case design method that exercises the logical conditions contained in a program module. A simple condition.
Written by: Dr. JJ Shepherd
A First Book of C++ Chapter 4 Selection. Objectives In this chapter, you will learn about: –Relational Expressions –The if-else Statement –Nested if Statements.
Flow of Control: Loops Module 4. Objectives Design a loop Use while, do, and for in a program Use the for-each with enumerations Use assertion checks.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
AP Java Ch. 4 Review Question 1  Java methods can return only primitive types (int, double, boolean, etc).
Mutation Testing Breaking the application to test it.
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Decisions and Iterations.
Foundations of Software Testing Chapter 7: Test Adequacy Measurement and Enhancement Using Mutation Last update: September 3, 2007 These slides are copyrighted.
Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?
Foundations of Software Testing Chapter 7: Test Adequacy Measurement and Enhancement Using Mutation Last update: September 3, 2007 These slides are copyrighted.
Mutation Testing Laraib Zahid & Mariam Arshad. What is Mutation Testing?  Fault-based Testing: directed towards “typical” faults that could occur in.
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
Semantic Analysis Type Checking
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.
Structural testing, Path Testing
SwE 455 Program Slicing.
Java Programming: Guided Learning with Early Objects
Introduction to Software Testing Chapter 9.2 Program-based Grammars
Introduction to Software Testing Chapter 5.2 Program-based Grammars
Software Testing Syntax-based Testing.
Institute of Computing Tech.
Mutation Testing The Mutants are Coming! Copyright © 2017 – Curt Hill.
Mutation Testing Moonzoo Kim School of Computing KAIST
Whitebox Testing.
HNDIT11034 More Operators.
CS 1054: Lecture 2, Chapter 1 Objects and Classes.
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:

MUTACINIS TESTAVIMAS Benediktas Knispelis, IFM-2/2 Mutation testing

Chapters About mutation testing Weak mutation testing Strong mutation testing Various mutation operators Tools for mutation testing Mutacinis testavimas 2 / 19

The aim of mutation testing Locate and expose weaknesses in test suites Mutacinis testavimas 3 / 19

Definition Mutacinis testavimas 4 / 19

About Mutation testing is also a type of white-box testing methods It involves modifying source code in small ways Mainly used for unit test cases Mutacinis testavimas 5 / 19

Mutation testing overview Mutation testing is done by selecting a set of mutation operators and then applying them to the source program one at a time for each applicable piece of the source code. The result of applying one mutation operator to the program is called a mutant. Mutacinis testavimas 6 / 19

Mutation testing overview (2) If the test suite is able to detect the change in the mutant code, then the mutant is said to be killed. When this happens, the mutant is considered dead and no longer needs to remain in the testing process since the faults represented by that mutant have been detected, and more importantly, it has satisfied its requirement of identifying a useful test case. Mutacinis testavimas 7 / 19

Mutation testing overview (3) If a mutant gives the same outcome as the original with the test data, then it is said to be live. The quality of a set of test cases is measured by the percentage of mutants killed by the test data (mutation score) MS = 100 * MK / (MA – ME) MK – quantity of mutants killed MA – overall quantity of mutants ME – quantity of equivalent mutants Mutacinis testavimas 8 / 19

Example The original code: if(a && b)c = 1; else c = 0; We replace '&&' with '||' and produce the following mutant: if(a || b)c = 1; else c = 0; Now, for the test to kill this mutant, the following condition should be met: 1) Test input data should cause different program states for the mutant and the original program. For example, a test with a=1 and b=0 would do this (enough for Weak mutation testing). 2) The value of 'c' should be propagated to the program's output and checked by the test (necessary for Strong mutation testing). Mutacinis testavimas 9 / 19

Weak mutation testing Weak mutation is an approximation technique that compares the internal states of the mutant and original program immediately after execution of the mutated portion of the program. It requires much less computing power to ensure that the test suite satisfies weak mutation testing. Mutacinis testavimas 10 / 19

Strong mutation testing When strong mutation testing is executed, the values produced by mutated code are passing further and change (or do not change) the output of the module or subroutine. If the mutant is not killed, then considerations are made whether it is possible to enhance test data to kill this live mutant or whether no test data could ever be constructed to kill the mutant. Strong mutation testing requires much more computing power. Mutacinis testavimas 11 / 19

Equivalent mutants The original code: int index=0; while (…){ index++; if (index == 10) break; } Replace "==" with ">=" and produce the following mutant: int index=0; while (…){ index++; if (index >= 10) break; } However, it is not possible to find a test case which could kill this mutant. Mutacinis testavimas 12 / 19

Traditional mutation operators 1. Statement deletion 2. Boolean expression changes (true and false) 3. Arithmetic operation changes (+ and *, - and /) 4. Boolean operator changes (> and >=, == and <=) 5. Changes of variables declared in the same scope (variable types should be the same) Mutacinis testavimas 13 / 19

Class-level mutation operators 1. Polymorphic 2. Method Overloading 3. Method Overriding/Hiding in Inheritance 4. Field Variable Hiding in Inheritance 5. Information Hiding (Access Control) 6. Static/Dynamic States of Objects 7. Exception Handling Mutacinis testavimas 14 / 19

Mutation testing tools NinjaTurtles (for mutation testing in.NET) Mutagenesis (a PHP 5.3+ mutation testing framework) Heckle (Ruby mutation tester) Jester (the JUnit test tester / JAVA) Mutandis (JavaScript) Mutacinis testavimas 15 / 19

NinjaTurtles Open-source Integrates with your existing unit test framework Mutation testing variants applied at IL level: Sequence point deletion Arithmetic operator substitution (*, /, +, - and %) Bitwise operator substitution (&, | and ^) Branch substitution (condition, always and never branch) Conditional boundary substitution ( and >=) Substitution of reads from variables, parameters and fields of the same type Substitution of writes to variables of the same type Mutacinis testavimas 16 / 19

NinjaTurtles Running mutation tests via console: NinjaTurtles.Console run -c ClassToTest TestAssembly.dll Supplementing existing test suites with mutation tests (C#): [Test, MutationTest] public void MethodUnderTest_Mutation_Tests() { MutationTestBuilder.For("MethodUnderTest").Run(); } Mutacinis testavimas 17 / 19

Questions 1. Aim of the mutation testing? 2. Mutation testing types? 3. Differences between strong and weak mutation testing? 4. What kind of traditional mutation operators do you know? 5. Is it possible to automate mutation testing? Mutacinis testavimas 18 / 19

Thank you Mutacinis testavimas 19 / 19