SlideShare a Scribd company logo
Mutation testing
Igor Gajowiak
July 2019
Igor Gajowiak 1 / 13
Why do we test our code ?
To ensure that code works properly
To have regression base for future development
Igor Gajowiak 2 / 13
What does test the tests ?
Code coverage index
Mutation testing ! ! !
Igor Gajowiak 3 / 13
Mutation testing
1 Prerequisites : Code base, test suite.
2 Run the test suite
3 Introduce small change to the code base - mutation
4 Run test suite
5 If the first test run succeeds and the second one not, then
it’s great !
Igor Gajowiak 4 / 13
Examples
Before :
1 f o r ( int i = 0; i < 100; ++i )
2 {
3 . . .
4 }
After :
1 f o r ( int i = 0; i > 100; ++i )
2 {
3 . . .
4 }
Igor Gajowiak 5 / 13
Examples
Before :
1 i f ( a && b)
2 {
3 c = 1;
4 }
After :
1 i f ( a | | b)
2 {
3 c = 1;
4 }
Igor Gajowiak 6 / 13
Result interpretation
Survived - tests did not detect change
Killed - tests detected change in the code
Incompetent - mutation produced flawed code
Igor Gajowiak 7 / 13
What is the goal ?
KILL THEM ALL
Igor Gajowiak 8 / 13
Code coverage vs mutation testing
Was a line executed ?
VS
Was a functionality verified ?
Igor Gajowiak 9 / 13
Examples of mutations
+ −
∗ /
< >
<
+ + i − − i
! = ==
continue break
|| &&
true false
Igor Gajowiak 10 / 13
It is time-consuming process
EXECUTION_TIME =
NUMBER_OF_MUTANTS * TEST_SUITE_EXECUTION_TIME
Solutions :
Parallelize
Write fast tests
Igor Gajowiak 11 / 13
Detecting incompetent mutants
1 while ( true )
2 {
3 . . .
4 i f ( condition )
5 {
6 break ;
7 }
8 . . .
9 }
1 while ( true )
2 {
3 . . .
4 i f ( condition )
5 {
6 continue ;
7 }
8 . . .
9 }
Igor Gajowiak 12 / 13
Stryker
Stryker - https://stryker-mutator.io
Supported mutations - https://github.com/stryker-
mutator/stryker-net/blob/master/docs/Mutators.md
Igor Gajowiak 13 / 13

More Related Content

PDF
What if Clippy Would Criticize Your Code? (benevol2015)
PPTX
Mutants vs Unit Tests - Kuba Ciechowski
PPT
Test Driven Development Part 1
PDF
Master's Degree thesis presentation
PDF
Programming katas for Software Testers - CounterStrings
PPTX
2016 10-04: tdd++: tdd made easier
DOCX
DSP Spring 2023 Lab Manual for spring 2023
PDF
Presentation slides: "How to get 100% code coverage"
What if Clippy Would Criticize Your Code? (benevol2015)
Mutants vs Unit Tests - Kuba Ciechowski
Test Driven Development Part 1
Master's Degree thesis presentation
Programming katas for Software Testers - CounterStrings
2016 10-04: tdd++: tdd made easier
DSP Spring 2023 Lab Manual for spring 2023
Presentation slides: "How to get 100% code coverage"

Similar to "Mutation Testing" by Igor Gajowiak (20)

PDF
MUTANTS KILLER - PIT: state of the art of mutation testing system
PDF
PHANTA: Diversified Test Code Quality Measurement for Modern Software Develop...
PDF
Test Dependencies and the Future of Build Acceleration
PDF
Treat Your Unit Tests As Production Code - DARGO - Amadeus - Soirée du Test L...
PPT
Test Infected Presentation
PPTX
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
PDF
C++ Unit Test with Google Testing Framework
PPTX
TDD Best Practices
PPT
Google test training
PDF
Finding Bugs, Fixing Bugs, Preventing Bugs - Exploiting Automated Tests to In...
PPTX
Basics of Automation & Manual Software Testing
PDF
Algorithm Analysis & Solution Design.pdf
PDF
Unit II - 3 - Operating System - Process Synchronization
PPTX
Building unit tests correctly with visual studio 2013
PPTX
Unit Testing in Android
PDF
White-box Testing: When Quality Really Matters
PDF
Sbst16 tooldemo.ppt
PDF
Sbst16 tooldemo.ppt
PPT
PPTX
Static analysis works for mission-critical systems, why not yours?
MUTANTS KILLER - PIT: state of the art of mutation testing system
PHANTA: Diversified Test Code Quality Measurement for Modern Software Develop...
Test Dependencies and the Future of Build Acceleration
Treat Your Unit Tests As Production Code - DARGO - Amadeus - Soirée du Test L...
Test Infected Presentation
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
C++ Unit Test with Google Testing Framework
TDD Best Practices
Google test training
Finding Bugs, Fixing Bugs, Preventing Bugs - Exploiting Automated Tests to In...
Basics of Automation & Manual Software Testing
Algorithm Analysis & Solution Design.pdf
Unit II - 3 - Operating System - Process Synchronization
Building unit tests correctly with visual studio 2013
Unit Testing in Android
White-box Testing: When Quality Really Matters
Sbst16 tooldemo.ppt
Sbst16 tooldemo.ppt
Static analysis works for mission-critical systems, why not yours?
Ad

Recently uploaded (20)

PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPT
Introduction Database Management System for Course Database
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
ai tools demonstartion for schools and inter college
PDF
Digital Strategies for Manufacturing Companies
PDF
Nekopoi APK 2025 free lastest update
PPTX
Transform Your Business with a Software ERP System
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Reimagine Home Health with the Power of Agentic AI​
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Introduction Database Management System for Course Database
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
ai tools demonstartion for schools and inter college
Digital Strategies for Manufacturing Companies
Nekopoi APK 2025 free lastest update
Transform Your Business with a Software ERP System
2025 Textile ERP Trends: SAP, Odoo & Oracle
Wondershare Filmora 15 Crack With Activation Key [2025
How to Migrate SBCGlobal Email to Yahoo Easily
Computer Software and OS of computer science of grade 11.pptx
How to Choose the Right IT Partner for Your Business in Malaysia
CHAPTER 2 - PM Management and IT Context
Navsoft: AI-Powered Business Solutions & Custom Software Development
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Operating system designcfffgfgggggggvggggggggg
Reimagine Home Health with the Power of Agentic AI​
Ad

"Mutation Testing" by Igor Gajowiak

  • 1. Mutation testing Igor Gajowiak July 2019 Igor Gajowiak 1 / 13
  • 2. Why do we test our code ? To ensure that code works properly To have regression base for future development Igor Gajowiak 2 / 13
  • 3. What does test the tests ? Code coverage index Mutation testing ! ! ! Igor Gajowiak 3 / 13
  • 4. Mutation testing 1 Prerequisites : Code base, test suite. 2 Run the test suite 3 Introduce small change to the code base - mutation 4 Run test suite 5 If the first test run succeeds and the second one not, then it’s great ! Igor Gajowiak 4 / 13
  • 5. Examples Before : 1 f o r ( int i = 0; i < 100; ++i ) 2 { 3 . . . 4 } After : 1 f o r ( int i = 0; i > 100; ++i ) 2 { 3 . . . 4 } Igor Gajowiak 5 / 13
  • 6. Examples Before : 1 i f ( a && b) 2 { 3 c = 1; 4 } After : 1 i f ( a | | b) 2 { 3 c = 1; 4 } Igor Gajowiak 6 / 13
  • 7. Result interpretation Survived - tests did not detect change Killed - tests detected change in the code Incompetent - mutation produced flawed code Igor Gajowiak 7 / 13
  • 8. What is the goal ? KILL THEM ALL Igor Gajowiak 8 / 13
  • 9. Code coverage vs mutation testing Was a line executed ? VS Was a functionality verified ? Igor Gajowiak 9 / 13
  • 10. Examples of mutations + − ∗ / < > < + + i − − i ! = == continue break || && true false Igor Gajowiak 10 / 13
  • 11. It is time-consuming process EXECUTION_TIME = NUMBER_OF_MUTANTS * TEST_SUITE_EXECUTION_TIME Solutions : Parallelize Write fast tests Igor Gajowiak 11 / 13
  • 12. Detecting incompetent mutants 1 while ( true ) 2 { 3 . . . 4 i f ( condition ) 5 { 6 break ; 7 } 8 . . . 9 } 1 while ( true ) 2 { 3 . . . 4 i f ( condition ) 5 { 6 continue ; 7 } 8 . . . 9 } Igor Gajowiak 12 / 13
  • 13. Stryker Stryker - https://stryker-mutator.io Supported mutations - https://github.com/stryker- mutator/stryker-net/blob/master/docs/Mutators.md Igor Gajowiak 13 / 13