SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
Mutation Testing
  Hernán Wilkinson             Nicolás Chillo     Gabriel Brunstein
     UBA - 10Pines                  UBA                 UBA
hernan.wilkinson@gmail.com
                             nchillo@gmail.com   gaboto@gmail.com
What is Mutation Testing?



Technique to verify the quality of the tests
What is Mutation Testing?

        Verify Quality of…           Verify Quality of…




Source Code                  Tests                   Mutation
                                                     Testing
How does it work?
     1st Step: Create the Mutant

                    Mutation
                    Process




The Source
   Code                                The “Mutant”




             The Mutation “Operator”
Examples
DebitCard>>= anotherDebitCard
 ^(type = anotherDebitCard type)
  and: [ number = anotherDebitCard number ]



                   Operator: Change #and: by #or:




CreditCard>>= anotherDebitCard
 ^(type = anotherDebitCard type)
   or: [ number = anotherDebitCard number ]
Examples
Purchase>>netPaid
 ^self totalPaid – self totalRefunded



                       Change #- with #+



Purchase>>netPaid
 ^self totalPaid + self totalRefunded
Why?
How does it help?
How does it work?
  2nd Step: Try to Kill the Mutant




                                  A Killer
  The “Mutant”           tries to kill the Mutant!


All tests run  The Mutant Survives!!!
                                                     The Test Suite
A test fails or errors  The Mutant Dies
Meaning…


The Mutant Survives  The case generated by the mutant
                     is not tested



The Mutant Dies  The case generated by the mutant is
                       tested
Example: The mutant survives
DebitCard>>= anotherDebitCard
 ^(type = anotherDebitCard type) and: [ number = anotherDebitCard number ]


                                             Operator: Change #and: by #or:

DebitCard>>= anotherDebitCard
 ^(type = anotherDebitCard type) or: [ number = anotherDebitCard number ]




DebitCardTest>>testDebitCardWithSameNumberShouldBeEqual
    self assert: (DebitCard visaNumbered: 123) = (DebitCard visaNumbered: 123).
Example: The mutant dies
DebitCard>>= anotherDebitCard
 ^(type = anotherDebitCard type) and: [ number = anotherDebitCard number ]


                                             Operator: Change #and: by #or:

DebitCard>>= anotherDebitCard
 ^(type = anotherDebitCard type) or: [ number = anotherDebitCard number ]




DebitCardTest>>testDebitCardWithSameNumberShouldBeEqual
    self assert: (DebitCard visaNumbered: 123) = (DebitCard visaNumbered: 123).


DebitCardTest >>testDebitCardWithDifferentNumberShouldBeDifferent
    self deny: (DebitCard visaNumbered: 123) = (DebitCard visaNumbered: 789).
Example: The mutant survives
Purchase>>netPaid
 ^self totalPaid – self totalRefunded

                                           Change #- with #+
Purchase>>netPaid
 ^self totalPaid + self totalRefunded


Purchase>>testNetPaid
   | purchase |
   purchase := Purchase for: 20 * euros.
   self assert: purchase netPaid = (purchase totalPaid – purchase totalRefunded)
Example: The mutant dies
Purchase>>netPaid
 ^self totalPaid – self totalRefunded

                                        Change #- with #+
Purchase>>netPaid
 ^self totalPaid + self totalRefunded


Purchase>>testNetPaidWithOutRefunds  Renamed!
   | purchase |
   purchase := Purchase for: 20 * euros.
   self assert: purchase netPaid = (purchase totalPaid – purchase totalRefunded)

Purchase>>testNetPaidWithRefunds
   | purchase |
   purchase := Purchase for: 20 * euros.
   purchase addRefundFor: 10 * euros.
   self assert: purchase netPaid = (purchase totalPaid – purchase totalRefunded)
How does it work? - Summary
• Changes the original source code with
  special “operators” to generate “Mutants”
• Run the test suite related to the changed
  code
  • If a test errors or fails  Kills the mutant
  • If all tests run  The Mutant survives
• Surviving Mutants show not tested cases


                 The Important Thing!
MuTalk



Mutation Testing Tool for Smalltalk (Pharo
              and Squeak)
Demo
MuTalk – How does it work?
•       Runs the test to be sure that all run
•       For each method m
    •       For each operator o
        •     Changes m AST using o
        •     Compiles mutated code
        •     Changes method dictionary
        •     Run the tests
MuTalk – Operators
•       Boolean messages
    •    Remove #not
    •    Replace #and: with #eqv:
    •    Replace #and: with #nand:
    •    Replace #and: with #or:
    •    Replace #and: with #secondArgResult:
    •    Replace #and: with false
    •    Replace #or: First Condition with false
    •    Replace #or: Second Condition with false
    •    Replace #or: with #and:
    •    Replace #or: with #xor:
MuTalk – Operators
•       Magnitude messages
    •    Replace #'<=' with #<
    •    Replace #'<=' with #=
    •    Replace #'<=' with #>
    •    Replace #'>=' with #=
    •    Replace #'>=' with #>
    •    Replace #'~=' with #=
    •    Replace #< with #>
    •    Replace #= with #'~='
    •    Replace #> with #<
    •    Replace #max: with #min:
    •    Replace #min: with #max:
MuTalk – Operators
•       Collection messages
    •     Remove at:ifAbsent:
    •     Replace #reject: with #select:
    •     Replace #select: with #reject:
    •     Replace Reject block with [:each | false]
    •     Replace Reject block with [:each | true]
    •     Replace Select block with [:each | false]
    •     Replace Select block with [:each | true]
    •     Replace detect: block with [:each | false] when #detect:ifNone:
    •     Replace detect: block with [:each | true] when #detect:ifNone:
    •     Replace do block with [:each |]
    •     Replace ifNone: block with [] when #detect:ifNone:
    •     Replace inject:aValue into:aBlock with aValue
    •     Replace sortBlock:aBlock with sortBlock:[:a :b| true]
MuTalk – Operators
•       Number messages
    •    Replace #* with #/
    •    Replace #+ with #-
    •    Replace #- with #+
    •    Replace #/ with #*
MuTalk – Operators
•       Flow control messages
    •     Remove Exception Handler Operator
    •     Replace #ifFalse: receiver with false
    •     Replace #ifFalse: receiver with true
    •     Replace #ifFalse: with #ifTrue:
    •     Replace #ifFalse:IfTrue: receiver with false
    •     Replace #ifFalse:IfTrue: receiver with true
    •     Replace #ifTrue: receiver with false
    •     Replace #ifTrue: receiver with true
    •     Replace #ifTrue: with #ifFalse:
    •     Replace #ifTrue:ifFalse: receiver with false
    •     Replace #ifTrue:ifFalse: receiver with true
Why is not widely used?
Is not new … - History

Begins in 1971, R. Lipton, “Fault Diagnosis of
            Computer Programs”

 Generally accepted in 1978, R. Lipton et al,
  “Hints on test data selection: Help for the
           practicing programmer”
Why is not widely used?


Maturity Problem: Because Testing is not
            widely used YET!
        (Although it is increasing)
Why is not widely used?


Integration Problem: Inability to successfully
  integrate it into the software development
                     process
         (TDD plays a key role now)
Why is not widely used?



Technical Problem: It is a Brute Force
             technique!
Technical Problems
• Brute force technique



                   NxM
      N = number of tests
      M = number of mutants
Aconcagua
•   Number of Tests: 666
•   Number of Mutants: 1005
•   Time to create a mutant/compile/link/run:
    10 secs. each aprox.?
•   Total time:
     –   6693300 seconds
     –   1859 hours, 15 minutes
Another way of doing it…
CreditCard>>= anotherCreditCard
 ^(anotherCreditCard isKindOf: self class) and: [ number =
  anotherCreditCard number ]


CreditCard>>= anotherCreditCard
 MutantId = 12 ifTrue: [ ^(anotherCreditCard isKindOf: self class) or: [
  number = anotherCreditCard number ].
 MutantId = 13 ifTrue: [ ^(anotherCreditCard isKindOf: self class)
  nand: [ number = anotherCreditCard number ].
 MutantId = 14 ifTrue: [ ^(anotherCreditCard isKindOf: self class) eqv: [
  number = anotherCreditCard number ].
Aconcagua
•   Number of Tests: 666
•   Number of Mutants: 1005
•   Time to create the
    metamutant/compile/link: 2 minutes?
•   Time to run the tests per mutant: 1 sec
•   Total time:
     –   1125 seconds
     –   18 minutes 45 seconds
MuTalk Optimizations
              Running Strategies
Mutate all methods, run all tests per       Mutate covered methods, run all
     mutant                                      tests per mutant
    –    Create a mutant for each method         –      Takes coverage running all tests
    –    Run all the test for each mutant        –      Mutate only covered methods
    –    Disadvantage: Slower strategy           –      Run all methods per mutant
                                                 –      Relies on coverage

Mutate all methods, run only test           Mutate covered methods, run only test
     that cover mutated method                    that covered mutated methods
    –    Run coverage keeping for each       –       Run coverage keeping for each
         method the tests that covered it            method the tests that covered it
    –    Create a mutant for each method     –       Create a mutant for only covered
    –    For each mutant, run only the               methods
         tests that covered the original     –       For each mutant, run only the tests
         method                                      that covered the original method
MuTalk - Aconcagua Statistics
•       Mutate All, Run All: 1 minute, 6 seconds
•       Mutate Covered, Run Covering: 36
        seconds
•       Result:
    •     545 Killed
    •     6 Terminated
    •     83 Survived
More Statistics
MuTalk Optimizations
Terminated Mutants




       Try to kill the Mutant!

       The killer has to be
       “Terminated”

                                 The Test Suite
MuTalk - Terminated Mutants


• Take the time it runs each test the first
  time
• If the test takes more thant 3 times,
  terminate it
Let’s redefine MuTalk as…

  Mutation Testing Tool for Smalltalk (Pharo
  and Squeak) that uses meta-facilities to
run faster and provide inmediate feedback
Work in progress


• Operators Categorization based on how
  useful they are to detect errors
• Filter Operators on View
• Cancel process
Future work

• Make Operators more “inteligent”
  • a = b ifTrue: [ … ]
    • a = b ifFalse: [] is equivalent to a ~= b ifTrue: []
• Suggest tests using not killed mutants
• Use MuTalk to test MuTalk?
Why does it work?


 “Complex faults are coupled to simple faults
in such a way that a test data set that detects
all simple faults in a program will detect most
       complex faults” (Coupling effect)
    Demonstrated in 1995, K. Wah, “Fault coupling in finite
                                      bijective functions”
Why does it work?


 “In practice, if the software contains a fault,
there will usually be a set of mutants that can
only be killed by a test case that also detects
                     that fault”
     Geist et al, “Estimation and enhancement of real-time
      software reliability through mutation analysis”, 1992
More Statistics…
How does it compare to
               coverage?
•       Does not replaces coverage because
        some methods do not generate mutants
•       But:
    •     Mutants on not covered methods will survive
    •     It provides better insight than coverage
    •     Method Coverage fails with long
          methods/conditions/loops/etc.
Questions?
MuTalk - Mutation
    Testing for Smalltalk

  Hernán Wilkinson             Nicolás Chillo     Gabriel Brunstein
     UBA - 10Pines                  UBA                 UBA
hernan.wilkinson@gmail.com
                             nchillo@gmail.com   gaboto@gmail.com

Contenu connexe

Tendances (20)

Test Management introduction
Test Management introductionTest Management introduction
Test Management introduction
 
Testing Metrics
Testing MetricsTesting Metrics
Testing Metrics
 
Mutation testing
Mutation testingMutation testing
Mutation testing
 
Non Functional Testing
Non Functional TestingNon Functional Testing
Non Functional Testing
 
Unit testing
Unit testing Unit testing
Unit testing
 
Test cases
Test casesTest cases
Test cases
 
Types of software testing
Types of software testingTypes of software testing
Types of software testing
 
Software testing
Software testingSoftware testing
Software testing
 
Basic interview questions for manual testing
Basic interview questions for manual testingBasic interview questions for manual testing
Basic interview questions for manual testing
 
Sonarqube
SonarqubeSonarqube
Sonarqube
 
Types of Software Testing | Edureka
Types of Software Testing | EdurekaTypes of Software Testing | Edureka
Types of Software Testing | Edureka
 
Software testing
Software testingSoftware testing
Software testing
 
Black box and white box testing
Black box and white box testingBlack box and white box testing
Black box and white box testing
 
Software Test Metrics and Measurements
Software Test Metrics and MeasurementsSoftware Test Metrics and Measurements
Software Test Metrics and Measurements
 
Non-functional Testing (NFT) Overview
Non-functional Testing (NFT) Overview Non-functional Testing (NFT) Overview
Non-functional Testing (NFT) Overview
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
What Is Functional Testing?
What Is Functional Testing?What Is Functional Testing?
What Is Functional Testing?
 
Software Testing Fundamentals
Software Testing FundamentalsSoftware Testing Fundamentals
Software Testing Fundamentals
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-concepts
 
Test Strategy
Test StrategyTest Strategy
Test Strategy
 

En vedette

Kill the mutants - A better way to test your tests
Kill the mutants - A better way to test your testsKill the mutants - A better way to test your tests
Kill the mutants - A better way to test your testsRoy van Rijn
 
Mutation testing
Mutation testingMutation testing
Mutation testingTao He
 
Mutation testing (OOP 2012, 2012-JAN-24)
Mutation testing (OOP 2012, 2012-JAN-24)Mutation testing (OOP 2012, 2012-JAN-24)
Mutation testing (OOP 2012, 2012-JAN-24)Filip Van Laenen
 
Mutation Testing
Mutation TestingMutation Testing
Mutation Testing10Pines
 
Kill the mutants and test your tests - Roy van Rijn
Kill the mutants and test your tests - Roy van RijnKill the mutants and test your tests - Roy van Rijn
Kill the mutants and test your tests - Roy van RijnNLJUG
 
Mutation Testing: Leaving the Stone Age. FOSDEM 2017
Mutation Testing: Leaving the Stone Age. FOSDEM 2017Mutation Testing: Leaving the Stone Age. FOSDEM 2017
Mutation Testing: Leaving the Stone Age. FOSDEM 2017Alex Denisov
 
An introduction to mutation testing
An introduction to mutation testingAn introduction to mutation testing
An introduction to mutation testingdavidmus
 
Mutagens
MutagensMutagens
MutagensUE
 
Test corner第三回, Charles 的使用經驗分享。
Test corner第三回, Charles 的使用經驗分享。Test corner第三回, Charles 的使用經驗分享。
Test corner第三回, Charles 的使用經驗分享。Su Sheng Chieh
 
Exploratory Testing Explained (Tampere Goes Agile - 2013)
Exploratory Testing Explained (Tampere Goes Agile - 2013)Exploratory Testing Explained (Tampere Goes Agile - 2013)
Exploratory Testing Explained (Tampere Goes Agile - 2013)Aleksis Tulonen
 
Exploratory Testing Explained and Experienced
Exploratory Testing Explained and ExperiencedExploratory Testing Explained and Experienced
Exploratory Testing Explained and ExperiencedMaaret Pyhäjärvi
 
Random testing
Random testingRandom testing
Random testingCan KAYA
 
xUnit Test Patterns - Chapter11
xUnit Test Patterns - Chapter11xUnit Test Patterns - Chapter11
xUnit Test Patterns - Chapter11Takuto Wada
 

En vedette (20)

Kill the mutants - A better way to test your tests
Kill the mutants - A better way to test your testsKill the mutants - A better way to test your tests
Kill the mutants - A better way to test your tests
 
Mutation testing
Mutation testingMutation testing
Mutation testing
 
Mutation testing (OOP 2012, 2012-JAN-24)
Mutation testing (OOP 2012, 2012-JAN-24)Mutation testing (OOP 2012, 2012-JAN-24)
Mutation testing (OOP 2012, 2012-JAN-24)
 
Mutation Testing
Mutation TestingMutation Testing
Mutation Testing
 
Mutation testing
Mutation testingMutation testing
Mutation testing
 
Kill the mutants and test your tests - Roy van Rijn
Kill the mutants and test your tests - Roy van RijnKill the mutants and test your tests - Roy van Rijn
Kill the mutants and test your tests - Roy van Rijn
 
Mutation Testing: Leaving the Stone Age. FOSDEM 2017
Mutation Testing: Leaving the Stone Age. FOSDEM 2017Mutation Testing: Leaving the Stone Age. FOSDEM 2017
Mutation Testing: Leaving the Stone Age. FOSDEM 2017
 
An introduction to mutation testing
An introduction to mutation testingAn introduction to mutation testing
An introduction to mutation testing
 
Mutagens
MutagensMutagens
Mutagens
 
Black box
Black boxBlack box
Black box
 
Black Box Testing
Black Box TestingBlack Box Testing
Black Box Testing
 
Test corner第三回, Charles 的使用經驗分享。
Test corner第三回, Charles 的使用經驗分享。Test corner第三回, Charles 的使用經驗分享。
Test corner第三回, Charles 的使用經驗分享。
 
Mutation Testing
Mutation TestingMutation Testing
Mutation Testing
 
Mutation testing in Java
Mutation testing in JavaMutation testing in Java
Mutation testing in Java
 
Exploratory Testing Explained (Tampere Goes Agile - 2013)
Exploratory Testing Explained (Tampere Goes Agile - 2013)Exploratory Testing Explained (Tampere Goes Agile - 2013)
Exploratory Testing Explained (Tampere Goes Agile - 2013)
 
Exploratory Testing Explained and Experienced
Exploratory Testing Explained and ExperiencedExploratory Testing Explained and Experienced
Exploratory Testing Explained and Experienced
 
A Taste of Exploratory Testing
A Taste of Exploratory TestingA Taste of Exploratory Testing
A Taste of Exploratory Testing
 
Random testing
Random testingRandom testing
Random testing
 
xUnit Test Patterns - Chapter11
xUnit Test Patterns - Chapter11xUnit Test Patterns - Chapter11
xUnit Test Patterns - Chapter11
 
Atm reconciliation manual
Atm reconciliation manualAtm reconciliation manual
Atm reconciliation manual
 

Similaire à Mutation Testing

Benchmarking and PHPBench
Benchmarking and PHPBenchBenchmarking and PHPBench
Benchmarking and PHPBenchdantleech
 
The Most Important Thing: How Mozilla Does Security and What You Can Steal
The Most Important Thing: How Mozilla Does Security and What You Can StealThe Most Important Thing: How Mozilla Does Security and What You Can Steal
The Most Important Thing: How Mozilla Does Security and What You Can Stealmozilla.presentations
 
Mutation Testing.pdf
Mutation Testing.pdfMutation Testing.pdf
Mutation Testing.pdfKeir Bowden
 
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...Steve Lange
 
EvoRobocode Competition @ GECCO-2013
EvoRobocode Competition @ GECCO-2013EvoRobocode Competition @ GECCO-2013
EvoRobocode Competition @ GECCO-2013Daniele Loiacono
 
Procedures, the Pop-11 stack and debugging
Procedures, the Pop-11 stack and debuggingProcedures, the Pop-11 stack and debugging
Procedures, the Pop-11 stack and debuggingRich Price
 
Tech Days 2015: Dynamic Analysis
Tech Days 2015: Dynamic AnalysisTech Days 2015: Dynamic Analysis
Tech Days 2015: Dynamic AnalysisAdaCore
 
Web 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web AppsWeb 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web Appsadunne
 
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...Steve Lange
 
The Unicorn's Travel to the Microcosm
The Unicorn's Travel to the MicrocosmThe Unicorn's Travel to the Microcosm
The Unicorn's Travel to the MicrocosmAndrey Karpov
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Béo Tú
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceJesse Vincent
 
Must.kill.mutants. TopConf Tallinn 2016
Must.kill.mutants. TopConf Tallinn 2016Must.kill.mutants. TopConf Tallinn 2016
Must.kill.mutants. TopConf Tallinn 2016Gerald Muecke
 
Joker - Improve your tests with mutation testing
Joker - Improve your tests with mutation testingJoker - Improve your tests with mutation testing
Joker - Improve your tests with mutation testingNicolas Fränkel
 
Test Smart, not hard
Test Smart, not hardTest Smart, not hard
Test Smart, not hardDiUS
 

Similaire à Mutation Testing (20)

des mutants dans le code.pdf
des mutants dans le code.pdfdes mutants dans le code.pdf
des mutants dans le code.pdf
 
Benchmarking and PHPBench
Benchmarking and PHPBenchBenchmarking and PHPBench
Benchmarking and PHPBench
 
The Most Important Thing: How Mozilla Does Security and What You Can Steal
The Most Important Thing: How Mozilla Does Security and What You Can StealThe Most Important Thing: How Mozilla Does Security and What You Can Steal
The Most Important Thing: How Mozilla Does Security and What You Can Steal
 
Mutation Testing.pdf
Mutation Testing.pdfMutation Testing.pdf
Mutation Testing.pdf
 
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
 
EvoRobocode Competition @ GECCO-2013
EvoRobocode Competition @ GECCO-2013EvoRobocode Competition @ GECCO-2013
EvoRobocode Competition @ GECCO-2013
 
Procedures, the Pop-11 stack and debugging
Procedures, the Pop-11 stack and debuggingProcedures, the Pop-11 stack and debugging
Procedures, the Pop-11 stack and debugging
 
Mutation-Testing mit PIT
Mutation-Testing mit PITMutation-Testing mit PIT
Mutation-Testing mit PIT
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
Test Automation Day 2018
Test Automation Day 2018Test Automation Day 2018
Test Automation Day 2018
 
Tech Days 2015: Dynamic Analysis
Tech Days 2015: Dynamic AnalysisTech Days 2015: Dynamic Analysis
Tech Days 2015: Dynamic Analysis
 
Web 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web AppsWeb 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web Apps
 
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocks
 
The Unicorn's Travel to the Microcosm
The Unicorn's Travel to the MicrocosmThe Unicorn's Travel to the Microcosm
The Unicorn's Travel to the Microcosm
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
 
Must.kill.mutants. TopConf Tallinn 2016
Must.kill.mutants. TopConf Tallinn 2016Must.kill.mutants. TopConf Tallinn 2016
Must.kill.mutants. TopConf Tallinn 2016
 
Joker - Improve your tests with mutation testing
Joker - Improve your tests with mutation testingJoker - Improve your tests with mutation testing
Joker - Improve your tests with mutation testing
 
Test Smart, not hard
Test Smart, not hardTest Smart, not hard
Test Smart, not hard
 

Plus de ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingESUG
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in PharoESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapESUG
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsESUG
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector TuningESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FutureESUG
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the DebuggerESUG
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing ScoreESUG
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptESUG
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsESUG
 

Plus de ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Dernier

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Dernier (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Mutation Testing

  • 1. Mutation Testing Hernán Wilkinson Nicolás Chillo Gabriel Brunstein UBA - 10Pines UBA UBA hernan.wilkinson@gmail.com nchillo@gmail.com gaboto@gmail.com
  • 2. What is Mutation Testing? Technique to verify the quality of the tests
  • 3. What is Mutation Testing? Verify Quality of… Verify Quality of… Source Code Tests Mutation Testing
  • 4. How does it work? 1st Step: Create the Mutant Mutation Process The Source Code The “Mutant” The Mutation “Operator”
  • 5. Examples DebitCard>>= anotherDebitCard ^(type = anotherDebitCard type) and: [ number = anotherDebitCard number ] Operator: Change #and: by #or: CreditCard>>= anotherDebitCard ^(type = anotherDebitCard type) or: [ number = anotherDebitCard number ]
  • 6. Examples Purchase>>netPaid ^self totalPaid – self totalRefunded Change #- with #+ Purchase>>netPaid ^self totalPaid + self totalRefunded
  • 8. How does it work? 2nd Step: Try to Kill the Mutant A Killer The “Mutant” tries to kill the Mutant! All tests run  The Mutant Survives!!! The Test Suite A test fails or errors  The Mutant Dies
  • 9. Meaning… The Mutant Survives  The case generated by the mutant is not tested The Mutant Dies  The case generated by the mutant is tested
  • 10. Example: The mutant survives DebitCard>>= anotherDebitCard ^(type = anotherDebitCard type) and: [ number = anotherDebitCard number ] Operator: Change #and: by #or: DebitCard>>= anotherDebitCard ^(type = anotherDebitCard type) or: [ number = anotherDebitCard number ] DebitCardTest>>testDebitCardWithSameNumberShouldBeEqual self assert: (DebitCard visaNumbered: 123) = (DebitCard visaNumbered: 123).
  • 11. Example: The mutant dies DebitCard>>= anotherDebitCard ^(type = anotherDebitCard type) and: [ number = anotherDebitCard number ] Operator: Change #and: by #or: DebitCard>>= anotherDebitCard ^(type = anotherDebitCard type) or: [ number = anotherDebitCard number ] DebitCardTest>>testDebitCardWithSameNumberShouldBeEqual self assert: (DebitCard visaNumbered: 123) = (DebitCard visaNumbered: 123). DebitCardTest >>testDebitCardWithDifferentNumberShouldBeDifferent self deny: (DebitCard visaNumbered: 123) = (DebitCard visaNumbered: 789).
  • 12. Example: The mutant survives Purchase>>netPaid ^self totalPaid – self totalRefunded Change #- with #+ Purchase>>netPaid ^self totalPaid + self totalRefunded Purchase>>testNetPaid | purchase | purchase := Purchase for: 20 * euros. self assert: purchase netPaid = (purchase totalPaid – purchase totalRefunded)
  • 13. Example: The mutant dies Purchase>>netPaid ^self totalPaid – self totalRefunded Change #- with #+ Purchase>>netPaid ^self totalPaid + self totalRefunded Purchase>>testNetPaidWithOutRefunds  Renamed! | purchase | purchase := Purchase for: 20 * euros. self assert: purchase netPaid = (purchase totalPaid – purchase totalRefunded) Purchase>>testNetPaidWithRefunds | purchase | purchase := Purchase for: 20 * euros. purchase addRefundFor: 10 * euros. self assert: purchase netPaid = (purchase totalPaid – purchase totalRefunded)
  • 14. How does it work? - Summary • Changes the original source code with special “operators” to generate “Mutants” • Run the test suite related to the changed code • If a test errors or fails  Kills the mutant • If all tests run  The Mutant survives • Surviving Mutants show not tested cases The Important Thing!
  • 15. MuTalk Mutation Testing Tool for Smalltalk (Pharo and Squeak)
  • 16. Demo
  • 17. MuTalk – How does it work? • Runs the test to be sure that all run • For each method m • For each operator o • Changes m AST using o • Compiles mutated code • Changes method dictionary • Run the tests
  • 18. MuTalk – Operators • Boolean messages • Remove #not • Replace #and: with #eqv: • Replace #and: with #nand: • Replace #and: with #or: • Replace #and: with #secondArgResult: • Replace #and: with false • Replace #or: First Condition with false • Replace #or: Second Condition with false • Replace #or: with #and: • Replace #or: with #xor:
  • 19. MuTalk – Operators • Magnitude messages • Replace #'<=' with #< • Replace #'<=' with #= • Replace #'<=' with #> • Replace #'>=' with #= • Replace #'>=' with #> • Replace #'~=' with #= • Replace #< with #> • Replace #= with #'~=' • Replace #> with #< • Replace #max: with #min: • Replace #min: with #max:
  • 20. MuTalk – Operators • Collection messages • Remove at:ifAbsent: • Replace #reject: with #select: • Replace #select: with #reject: • Replace Reject block with [:each | false] • Replace Reject block with [:each | true] • Replace Select block with [:each | false] • Replace Select block with [:each | true] • Replace detect: block with [:each | false] when #detect:ifNone: • Replace detect: block with [:each | true] when #detect:ifNone: • Replace do block with [:each |] • Replace ifNone: block with [] when #detect:ifNone: • Replace inject:aValue into:aBlock with aValue • Replace sortBlock:aBlock with sortBlock:[:a :b| true]
  • 21. MuTalk – Operators • Number messages • Replace #* with #/ • Replace #+ with #- • Replace #- with #+ • Replace #/ with #*
  • 22. MuTalk – Operators • Flow control messages • Remove Exception Handler Operator • Replace #ifFalse: receiver with false • Replace #ifFalse: receiver with true • Replace #ifFalse: with #ifTrue: • Replace #ifFalse:IfTrue: receiver with false • Replace #ifFalse:IfTrue: receiver with true • Replace #ifTrue: receiver with false • Replace #ifTrue: receiver with true • Replace #ifTrue: with #ifFalse: • Replace #ifTrue:ifFalse: receiver with false • Replace #ifTrue:ifFalse: receiver with true
  • 23. Why is not widely used?
  • 24. Is not new … - History Begins in 1971, R. Lipton, “Fault Diagnosis of Computer Programs” Generally accepted in 1978, R. Lipton et al, “Hints on test data selection: Help for the practicing programmer”
  • 25. Why is not widely used? Maturity Problem: Because Testing is not widely used YET! (Although it is increasing)
  • 26. Why is not widely used? Integration Problem: Inability to successfully integrate it into the software development process (TDD plays a key role now)
  • 27. Why is not widely used? Technical Problem: It is a Brute Force technique!
  • 28. Technical Problems • Brute force technique NxM N = number of tests M = number of mutants
  • 29. Aconcagua • Number of Tests: 666 • Number of Mutants: 1005 • Time to create a mutant/compile/link/run: 10 secs. each aprox.? • Total time: – 6693300 seconds – 1859 hours, 15 minutes
  • 30. Another way of doing it… CreditCard>>= anotherCreditCard ^(anotherCreditCard isKindOf: self class) and: [ number = anotherCreditCard number ] CreditCard>>= anotherCreditCard MutantId = 12 ifTrue: [ ^(anotherCreditCard isKindOf: self class) or: [ number = anotherCreditCard number ]. MutantId = 13 ifTrue: [ ^(anotherCreditCard isKindOf: self class) nand: [ number = anotherCreditCard number ]. MutantId = 14 ifTrue: [ ^(anotherCreditCard isKindOf: self class) eqv: [ number = anotherCreditCard number ].
  • 31. Aconcagua • Number of Tests: 666 • Number of Mutants: 1005 • Time to create the metamutant/compile/link: 2 minutes? • Time to run the tests per mutant: 1 sec • Total time: – 1125 seconds – 18 minutes 45 seconds
  • 32. MuTalk Optimizations Running Strategies Mutate all methods, run all tests per Mutate covered methods, run all mutant tests per mutant – Create a mutant for each method – Takes coverage running all tests – Run all the test for each mutant – Mutate only covered methods – Disadvantage: Slower strategy – Run all methods per mutant – Relies on coverage Mutate all methods, run only test Mutate covered methods, run only test that cover mutated method that covered mutated methods – Run coverage keeping for each – Run coverage keeping for each method the tests that covered it method the tests that covered it – Create a mutant for each method – Create a mutant for only covered – For each mutant, run only the methods tests that covered the original – For each mutant, run only the tests method that covered the original method
  • 33. MuTalk - Aconcagua Statistics • Mutate All, Run All: 1 minute, 6 seconds • Mutate Covered, Run Covering: 36 seconds • Result: • 545 Killed • 6 Terminated • 83 Survived
  • 35. MuTalk Optimizations Terminated Mutants Try to kill the Mutant! The killer has to be “Terminated” The Test Suite
  • 36. MuTalk - Terminated Mutants • Take the time it runs each test the first time • If the test takes more thant 3 times, terminate it
  • 37. Let’s redefine MuTalk as… Mutation Testing Tool for Smalltalk (Pharo and Squeak) that uses meta-facilities to run faster and provide inmediate feedback
  • 38. Work in progress • Operators Categorization based on how useful they are to detect errors • Filter Operators on View • Cancel process
  • 39. Future work • Make Operators more “inteligent” • a = b ifTrue: [ … ] • a = b ifFalse: [] is equivalent to a ~= b ifTrue: [] • Suggest tests using not killed mutants • Use MuTalk to test MuTalk?
  • 40. Why does it work? “Complex faults are coupled to simple faults in such a way that a test data set that detects all simple faults in a program will detect most complex faults” (Coupling effect) Demonstrated in 1995, K. Wah, “Fault coupling in finite bijective functions”
  • 41. Why does it work? “In practice, if the software contains a fault, there will usually be a set of mutants that can only be killed by a test case that also detects that fault” Geist et al, “Estimation and enhancement of real-time software reliability through mutation analysis”, 1992
  • 43. How does it compare to coverage? • Does not replaces coverage because some methods do not generate mutants • But: • Mutants on not covered methods will survive • It provides better insight than coverage • Method Coverage fails with long methods/conditions/loops/etc.
  • 45. MuTalk - Mutation Testing for Smalltalk Hernán Wilkinson Nicolás Chillo Gabriel Brunstein UBA - 10Pines UBA UBA hernan.wilkinson@gmail.com nchillo@gmail.com gaboto@gmail.com