SlideShare a Scribd company logo
MUTATION TESTING
Mateusz Bryła - Mutation testing
Woot?
EXAMPLE 1
public void testMethod() {
Something something = new Something();
something.executeSomeMethod();
}
EXAMPLE 2
public void testConstructor() {
Something something = new Something();
}
LITTLE HISTORY
FIRST PROPOSED in 1971 by Richard Lipton
A. Jefferson Offutt and R. H. Untch “Mutation 2000: Uniting the Orthogonal”
FIRST DEFINED in 1978
R. A. De Millo, R. J. Lipton, F. G. Sayward “Hints on test data selection”
FIRST IMPLEMENTED in 1980 by Timothy Budd
T. A. Budd, “Mutation Analysis of Program Test Data”
PROBLEM
SOLUTION
EXPECTATIONS
TESTS - TDD?
TESTS - NO TDD?
TEST
MUTATION
TESTING MUTATED CODE...
EXPECTED RESULT
SOMETHING WRONG?
Mateusz Bryła - Mutation testing
FLOW
1. Run tests
2. Mutate production code
3. Run tests again
4. Generate report
KILL THE MUTANT!
TESTS RESULTS?
PASSED (SURVIVED) FAILED (KILLED)
other results applicable (e. g. timeout, memory error)
EXAMPLE
ORIGINAL
if (i >= 0) {
return "foo";
} else {
return "bar";
}
MUTATED
if (i > 0) {
return "foo";
} else {
return "bar";
}
conditionals boundary mutation
COMMON MUTATORS #1
CONDITIONALS MUTATORS
< -> <=
<= -> <
> -> >=
>= -> >
== -> !=
!= -> ==
MATH MUTATORS
+ -> -
- -> +
>> -> <<
<< -> >>
* -> /
/ -> *
COMMON MUTATORS #2
RETURN VALUES MUTATOR
returns true if original returns false
returns false if original returns true
returns 0 if original returns int != 0
returns 1 if original returns 0
METHOD CALLS MUTATOR
removes void method call
removes non-void method call, returns default
value for the return type
replaces members with null in constructors
SURVIVORS STORIES
HOW TO GET STARTED?
PITEST for JAVA http://pitest.org
Parasoft INSURE++ for C/C++ https://www.parasoft.com/product/insure/
MutPy for Python https://pypi.python.org/pypi/MutPy/0.4.0
Maven: mvn org.pitest:pitest-maven:mutationCoverage
PERFORMANCE
100 classes
10 tests / class
1 ms / test
tTOTAL = 100 x 10 x 1ms = 1s
10 mutations / class
tALL = 10 x 100 x 1s ~ 17min
tSMART = 10 x 100 x (10 x 1ms) = 10s
1000 classes
10 tests / class
1 ms / test
tTOTAL = 1000 x 10 x 1ms = 10s
10 mutations / class
tALL = 10 x 1000 x 10s ~ 28h
tSMART = 10 x 1000 x (10 x 1ms) ~ 2min
real life example: 481 test cases fully mutated on 16GB i7 -> 03:24 min
Mateusz Bryła - Mutation testing
ATTRIBUTIONS
Hands Up - Avel Chuklanov - https://unsplash.com/photos/9cx4-QowgLc (CC0 1.0)
Bridge - Franc - https://thenounproject.com/search/?q=bridge&i=122542 (CC BY 3.0 US)
Cargo Truck - No way - https://thenounproject.com/search/?q=truck&i=154864 (CC0 1.0)
Philosoraptor - OnlyOneKenobi - http://wallpaperswide.com/philosoraptor-wallpapers.html
Chainsaw - James Keuning - https://thenounproject.com/search/?q=chainsaw&i=11328 (CC0 1.0)
Refugees - Gerald Wildmoser - https://thenounproject.com/search/?q=drown&i=208787 (CC BY 3.0 US)
Resurrection - Isabel Martinez Isabel - https://thenounproject.com/search/?q=survived&i=202842 (CC BY 3.0 US)
Pac Man - iconoci - https://thenounproject.com/search/?q=pac+man&i=9215 (CC BY 3.0 US)
Stopwatch - Nick Holroyd - https://thenounproject.com/search/?q=stopwatch&i=12666 (CC BY 3.0 US)
Zombie analysis - clement127 - https://www.flickr.com/photos/clement127/16089737804/ (CC BY-NC-ND 2.0)
in order of appearance
THANK YOU!
Mateusz Bryła

More Related Content

PDF
KraQA #22, Filip Cynarski - Selenium Grid w chmurze Amazon Web Services
PDF
TestowanieIoT2016
PDF
Verruga Peruana: An Infectious Endemic Angiomatosis
PPTX
День Матери
DOCX
Morresha Speight Resume
PDF
Marçojardim
PDF
World of Champions (2)
PPTX
Extensibility with sl4 and mef (pt)
KraQA #22, Filip Cynarski - Selenium Grid w chmurze Amazon Web Services
TestowanieIoT2016
Verruga Peruana: An Infectious Endemic Angiomatosis
День Матери
Morresha Speight Resume
Marçojardim
World of Champions (2)
Extensibility with sl4 and mef (pt)

Viewers also liked (13)

PPTX
M sc advanced food marketing finding info
PPTX
Lição 8 Não Matarás
PDF
NI Local Conference One Pager_NISF_29 April 2017(3)
PDF
Guide aides financieres renovation habitat - juillet -2016
PDF
demola_presentation
DOCX
Relatório de desenho
PPTX
фольклорні балади про робін гуда
PPTX
Connecting in the Facebook Age: Development and Validation of a New Measure o...
DOC
Resolución pliegos nutrición adulto mayor
DOCX
Creating my contents page
PDF
Apn super bônus
DOCX
Brian Ramirez-Letter of Recommendation
PDF
AIXÍ ÉS LA MEVA ESCOLA!
M sc advanced food marketing finding info
Lição 8 Não Matarás
NI Local Conference One Pager_NISF_29 April 2017(3)
Guide aides financieres renovation habitat - juillet -2016
demola_presentation
Relatório de desenho
фольклорні балади про робін гуда
Connecting in the Facebook Age: Development and Validation of a New Measure o...
Resolución pliegos nutrición adulto mayor
Creating my contents page
Apn super bônus
Brian Ramirez-Letter of Recommendation
AIXÍ ÉS LA MEVA ESCOLA!
Ad

Similar to Mateusz Bryła - Mutation testing (20)

PDF
Mutation Testing: Start Hunting The Bugs
PPTX
Mutation testing
PDF
Fuzzing for CPS Mutation Testing
PDF
Mutation and Contract Testing
PDF
Stamp breizhcamp 2019
PDF
Basic TDD moves
PDF
STAMP Descartes Presentation
PDF
Mutation testing
PDF
20150603 establishing theoretical minimal sets of mutants (Lab seminar)
PPTX
Kill the mutants and test your tests - Roy van Rijn
PDF
Kill the mutants - A better way to test your tests
PDF
Tdd with python unittest for embedded c
PDF
Mutation @ Spotify
PDF
DSR Testing (Part 1)
PPTX
Mutation-Testing mit PIT
KEY
Test-driven Development for TYPO3
PPT
Print Testing
PPT
Convergence
PDF
MUTANTS KILLER - PIT: state of the art of mutation testing system
KEY
Test-driven development for TYPO3 (T3DD11)
Mutation Testing: Start Hunting The Bugs
Mutation testing
Fuzzing for CPS Mutation Testing
Mutation and Contract Testing
Stamp breizhcamp 2019
Basic TDD moves
STAMP Descartes Presentation
Mutation testing
20150603 establishing theoretical minimal sets of mutants (Lab seminar)
Kill the mutants and test your tests - Roy van Rijn
Kill the mutants - A better way to test your tests
Tdd with python unittest for embedded c
Mutation @ Spotify
DSR Testing (Part 1)
Mutation-Testing mit PIT
Test-driven Development for TYPO3
Print Testing
Convergence
MUTANTS KILLER - PIT: state of the art of mutation testing system
Test-driven development for TYPO3 (T3DD11)
Ad

More from kraqa (20)

PDF
RestAssured w sluzbie testow API
PDF
Postman - podstawy testowania REST API
PDF
Stanislaw potoczny kra_qa_21.01.20
PDF
Machine learning powered regression - KraQA 42 - Pawel Dyrek
PDF
Kontrakt testy - KraQA 42 - Slawomir Radzyminski
PDF
KraQA#41 - PageFactory
PPTX
KraQA#39 - Jak testowac tool do testow
PDF
Hyperion - wystarczy jeden shake
PPTX
Wybor urzadzen mobilnych do testow
PDF
Continuous security
PDF
Let s meet inside
PDF
O wezu przy kawie
PPTX
Strategia do automatów
PPTX
Z czym do api
PPTX
Jenkins pipelines
PDF
Testy UI
PDF
Tester w pułapce myślenia
PDF
Kiedy tester zostaje managerem
PPT
KraQA#32 - RODO
PDF
SkładQA 2018 - Daniel Dec
RestAssured w sluzbie testow API
Postman - podstawy testowania REST API
Stanislaw potoczny kra_qa_21.01.20
Machine learning powered regression - KraQA 42 - Pawel Dyrek
Kontrakt testy - KraQA 42 - Slawomir Radzyminski
KraQA#41 - PageFactory
KraQA#39 - Jak testowac tool do testow
Hyperion - wystarczy jeden shake
Wybor urzadzen mobilnych do testow
Continuous security
Let s meet inside
O wezu przy kawie
Strategia do automatów
Z czym do api
Jenkins pipelines
Testy UI
Tester w pułapce myślenia
Kiedy tester zostaje managerem
KraQA#32 - RODO
SkładQA 2018 - Daniel Dec

Recently uploaded (20)

PPTX
CH1 Production IntroductoryConcepts.pptx
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Construction Project Organization Group 2.pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPT
Project quality management in manufacturing
PDF
PPT on Performance Review to get promotions
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Sustainable Sites - Green Building Construction
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
additive manufacturing of ss316l using mig welding
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
web development for engineering and engineering
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPT
Mechanical Engineering MATERIALS Selection
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
CH1 Production IntroductoryConcepts.pptx
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
UNIT 4 Total Quality Management .pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Lecture Notes Electrical Wiring System Components
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Construction Project Organization Group 2.pptx
R24 SURVEYING LAB MANUAL for civil enggi
Project quality management in manufacturing
PPT on Performance Review to get promotions
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Sustainable Sites - Green Building Construction
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
additive manufacturing of ss316l using mig welding
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
web development for engineering and engineering
Automation-in-Manufacturing-Chapter-Introduction.pdf
Mechanical Engineering MATERIALS Selection
Foundation to blockchain - A guide to Blockchain Tech
Mitigating Risks through Effective Management for Enhancing Organizational Pe...

Mateusz Bryła - Mutation testing

  • 3. Woot? EXAMPLE 1 public void testMethod() { Something something = new Something(); something.executeSomeMethod(); } EXAMPLE 2 public void testConstructor() { Something something = new Something(); }
  • 4. LITTLE HISTORY FIRST PROPOSED in 1971 by Richard Lipton A. Jefferson Offutt and R. H. Untch “Mutation 2000: Uniting the Orthogonal” FIRST DEFINED in 1978 R. A. De Millo, R. J. Lipton, F. G. Sayward “Hints on test data selection” FIRST IMPLEMENTED in 1980 by Timothy Budd T. A. Budd, “Mutation Analysis of Program Test Data”
  • 9. TESTS - NO TDD?
  • 10. TEST
  • 16. FLOW 1. Run tests 2. Mutate production code 3. Run tests again 4. Generate report
  • 18. TESTS RESULTS? PASSED (SURVIVED) FAILED (KILLED) other results applicable (e. g. timeout, memory error)
  • 19. EXAMPLE ORIGINAL if (i >= 0) { return "foo"; } else { return "bar"; } MUTATED if (i > 0) { return "foo"; } else { return "bar"; } conditionals boundary mutation
  • 20. COMMON MUTATORS #1 CONDITIONALS MUTATORS < -> <= <= -> < > -> >= >= -> > == -> != != -> == MATH MUTATORS + -> - - -> + >> -> << << -> >> * -> / / -> *
  • 21. COMMON MUTATORS #2 RETURN VALUES MUTATOR returns true if original returns false returns false if original returns true returns 0 if original returns int != 0 returns 1 if original returns 0 METHOD CALLS MUTATOR removes void method call removes non-void method call, returns default value for the return type replaces members with null in constructors
  • 23. HOW TO GET STARTED? PITEST for JAVA http://pitest.org Parasoft INSURE++ for C/C++ https://www.parasoft.com/product/insure/ MutPy for Python https://pypi.python.org/pypi/MutPy/0.4.0 Maven: mvn org.pitest:pitest-maven:mutationCoverage
  • 24. PERFORMANCE 100 classes 10 tests / class 1 ms / test tTOTAL = 100 x 10 x 1ms = 1s 10 mutations / class tALL = 10 x 100 x 1s ~ 17min tSMART = 10 x 100 x (10 x 1ms) = 10s 1000 classes 10 tests / class 1 ms / test tTOTAL = 1000 x 10 x 1ms = 10s 10 mutations / class tALL = 10 x 1000 x 10s ~ 28h tSMART = 10 x 1000 x (10 x 1ms) ~ 2min real life example: 481 test cases fully mutated on 16GB i7 -> 03:24 min
  • 26. ATTRIBUTIONS Hands Up - Avel Chuklanov - https://unsplash.com/photos/9cx4-QowgLc (CC0 1.0) Bridge - Franc - https://thenounproject.com/search/?q=bridge&i=122542 (CC BY 3.0 US) Cargo Truck - No way - https://thenounproject.com/search/?q=truck&i=154864 (CC0 1.0) Philosoraptor - OnlyOneKenobi - http://wallpaperswide.com/philosoraptor-wallpapers.html Chainsaw - James Keuning - https://thenounproject.com/search/?q=chainsaw&i=11328 (CC0 1.0) Refugees - Gerald Wildmoser - https://thenounproject.com/search/?q=drown&i=208787 (CC BY 3.0 US) Resurrection - Isabel Martinez Isabel - https://thenounproject.com/search/?q=survived&i=202842 (CC BY 3.0 US) Pac Man - iconoci - https://thenounproject.com/search/?q=pac+man&i=9215 (CC BY 3.0 US) Stopwatch - Nick Holroyd - https://thenounproject.com/search/?q=stopwatch&i=12666 (CC BY 3.0 US) Zombie analysis - clement127 - https://www.flickr.com/photos/clement127/16089737804/ (CC BY-NC-ND 2.0) in order of appearance

Editor's Notes

  • #2: Welcome everyone!
  • #3: Show of hands! Who writes unit tests? Who believes they are worthy? Who measures coverage? Who has coverage at >= 85%? Who thinks coverage is the perfect metric? Nice tool. But it isn’t perfect.
  • #5: 1971 - proposed by a student RICHARD LIPTON as a term work. 1978 - formal definition 1980 - first implementation But TOO SLOW!
  • #19: PASSED - negative scenario FAILED - positive scenario
  • #23: Story 1 - forgot to clear map - show example Story 2 - rare fault handling - one boolean method returning failure handling result - all unit tests expected false as return method - in mocking nightmare