SlideShare a Scribd company logo
1 of 23
Download to read offline
TejaSoft Innovations Pvt. Ltd.
nagendra.raja@tejasoft.com,
+91-9886723872
UNIT TESTS QUALITY
BENDING
#techdebt
By recognizing Fake Tests
TYPES OF TESTING
PURPOSE OF UNIT TESTS
To know what
developers have
understood as method
level requirment
Avoid repeat manual
pre-commit testing by
Developers
To make sure
regressions are caught
if the main code
changed
To make sure
Developers get to
know bugs much much
before QA team can
report
Bring in Automation to
speed up
development
Help Developers
Identify the Unit Level
Mistake (reduce
debugging time) & Fix
bugs with ease
UNIT TESTING SMELLS/QUALITY GAPS
• Empty Unit Tests
• No Asserts
• Wrong Asserts – They should have failed but pass
• @Ignore and commented test code
Fake Unit
Tests
• Even after 100% Cover Coverage, still many production or QA reported issues
• New Code that conflicted past requirement should have failed past Unit tests, but it
does not
Tests are
Not Enough
• Too Much of Mocking
• Flickering
• Interdependencies
• Long Running
• Magic Numbers
Complexity
Vaccine created DEFENCE MECHANISM
SHOULD KILL (Unit Tests should fail) mutated
VIRUSES – then Vaccine is effective
If Mutated VIRUS survives (all unit tests pass),
then Unit Tests are not enough.
WHAT DOES MUTATION MEAN?
Mutation - Change Main CODE
and see if Unit Tests catch (fail)
What is mutation testing?
Bugs, or mutants, are automatically inserted into your
production code. Your tests are run for each mutant. If your
tests fail then the mutant is killed. If your tests passed, the
mutant survived. The higher the percentage of mutants killed,
the more effective your tests are.
HOW TO CREATE THE MUTANTS!
Operator mutations About 30 different patterns like replacing + by - , * by ** and similar, but also > by >=
Keyword mutations Replacing true by false , in by not in and similar
Number mutations You can write things like 0b100 which is the same as 4, 0o100, which is 64, 0x100 which is
256, .12 which is 0.12 and similar. The number mutations try to capture mistakes in this area.
mutmut simply adds 1 to the number.
Name mutations The name mutations capture copy vs deepcopy and "" vs None .
Argument mutations Replaces keyword arguments one by one from dict(a=b) to dict(aXXX=b)
or_test and and_test and ↔ or
String mutation Adding XX to the string
Collections mutations Add Junk Elements or Remove Few elements from List or Array
Value Modify Modify the VALUE of results of method calls
Inject method calls Add get or setter methods multiple times in place of one call
Comment the CODE Remove some code or stop the methods being called
https://pitest.org/quickstart/mutators/
3 TYPES OF MUTATION TESTING
1. DECISION MUTATION
control statements are to be changed
2. STATEMENT MUTATION
developer cut and pastes a part of a code of which
the outcome may be a removal of some lines
3. VALUE MUTATION
values of primary parameters are modified
WARNING
May take FOREVER TO RUN
CODE - WORKSHOP
‘KATA’ MODULE – CODE WALKTHROUGH
1. Company and Employee classes
2. CompanyRunner – Explain & Execute Main – With Code
Coverage
3. CompanyTest – Explain & Execute Unit Tests – With Code
Coverage
4. Run PITEST kata – Explain, Execute and Show the HTML
Report
‘FIX’ MODULE – CODE WALKTHROUGH
1. CompanyRunnerFixed – Explain & Execute Main – With
Code Coverage
2. CompanyTestFixed – Explain & Execute Unit Tests – With
Code Coverage
3. Run PITEST fix – Explain, Execute and Show the HTML
Report
4. CompanyFixed and EmployeeFixed classes
CODE COVERAGE VS MUTATION
Code coverage doesn't tell you everything about the effectiveness of your tests.
Think about it, when was the last time you saw a test without an assertion, purely
to increase the code coverage
Imagine a sandwich covered with chocolate paste
Code coverage would tell you the bread is 80% covered with paste, does not
differentiate what kind of paste is it.
Mutation testing, on the other hand, would tell you it is actually chocolate paste and
not... well... something else if paste is not chocolate
REGRESSIONS VS MUTATION - TESTING
1. Regressions are unintended
Since the vast majority of tests have been added due to previous bugs hence, if
they find a problem, you have regressed to a previous state (in which the
problem once again exists). High Failure Rates is, failure of the main code quality
2. Mutation are intended
In Mutation testing framework would intentionally introduce small errors (called
mutations) into your application and test failure are expected. More failures rate
is high quality of Unit Testing
REFERENCES
LANGUAGE Mutation Testing Frameworks
Java 1. PIT (GitHub)
https://github.com/vmzakharov/mutate-test-kata - Big Thanks to @vmzakharov, as code and insights of what all I shared is his CODE
only (#tejasoft https://github.com/nagkumar/mutate-test-kata only refactored it)
Different Mutators: https://pitest.org/quickstart/mutators/, https://pitest.org/quickstart/commandline/
2. Jumble - http://jumble.sourceforge.net/
3. µJava - http://cs.gmu.edu/offutt/mujava/
4. Jester - http://jester.sourceforge.net/
5. Javalanche - https://github.com/david-schuler/javalanche
6. tsDetect : https://github.com/TestSmells/TestSmellDetector - Code Smells Detector
C / C++ Mull
C# Visualmutator, Nester
JavaScript Stryker
PHP Infection (formerly called humbug)
Ruby Mutant
Rust mutagen
Swift Muter
Python https://pypi.org/project/mutmut/
MAINTAIN DISCIPLINE
Do not cut corners, else
end up with code and tests
of “usual (IT Services)”
quality
Q&A
What Gives at most Engineering Kick & Confidence?
Production No Production Fires - Code Just
Works
Developers Unit/Mutation Tests Keep Failing
QA Team Developers accept BUG as Bug
Better code Each Day
Mutation Testing

More Related Content

What's hot

An introduction to unit testing
An introduction to unit testingAn introduction to unit testing
An introduction to unit testingAdam Stephensen
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
Defects in software testing
Defects in software testingDefects in software testing
Defects in software testingsandeepsingh2808
 
Bug life cycle
Bug life cycleBug life cycle
Bug life cycleBugRaptors
 
Regression testing
Regression testingRegression testing
Regression testingHarsh verma
 
01 software test engineering (manual testing)
01 software test engineering (manual testing)01 software test engineering (manual testing)
01 software test engineering (manual testing)Siddireddy Balu
 
Survey on Software Defect Prediction
Survey on Software Defect PredictionSurvey on Software Defect Prediction
Survey on Software Defect PredictionSung Kim
 
Software Testing Introduction
Software Testing IntroductionSoftware Testing Introduction
Software Testing IntroductionArunKumar5524
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first stepsRenato Primavera
 
Basic interview questions for manual testing
Basic interview questions for manual testingBasic interview questions for manual testing
Basic interview questions for manual testingJYOTI RANJAN PAL
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-conceptsmedsherb
 

What's hot (20)

An introduction to unit testing
An introduction to unit testingAn introduction to unit testing
An introduction to unit testing
 
Testing
TestingTesting
Testing
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Negative Testing
Negative TestingNegative Testing
Negative Testing
 
Code review
Code reviewCode review
Code review
 
Defects in software testing
Defects in software testingDefects in software testing
Defects in software testing
 
Bug life cycle
Bug life cycleBug life cycle
Bug life cycle
 
Regression testing
Regression testingRegression testing
Regression testing
 
Unit testing
Unit testingUnit testing
Unit testing
 
01 software test engineering (manual testing)
01 software test engineering (manual testing)01 software test engineering (manual testing)
01 software test engineering (manual testing)
 
Survey on Software Defect Prediction
Survey on Software Defect PredictionSurvey on Software Defect Prediction
Survey on Software Defect Prediction
 
Presentation on Agile Testing
Presentation on Agile TestingPresentation on Agile Testing
Presentation on Agile Testing
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
 
Code Review
Code ReviewCode Review
Code Review
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Software Testing Introduction
Software Testing IntroductionSoftware Testing Introduction
Software Testing Introduction
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first steps
 
Basic interview questions for manual testing
Basic interview questions for manual testingBasic interview questions for manual testing
Basic interview questions for manual testing
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-concepts
 

Similar to Mutation Testing

Making the Unstable Stable - An Intro To Testing
Making the Unstable Stable - An Intro To TestingMaking the Unstable Stable - An Intro To Testing
Making the Unstable Stable - An Intro To TestingCameron Presley
 
Must.Kill.Mutants. Agile Testing Days 2017
Must.Kill.Mutants. Agile Testing Days 2017Must.Kill.Mutants. Agile Testing Days 2017
Must.Kill.Mutants. Agile Testing Days 2017Gerald Muecke
 
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
Agile Mumbai 2020 Conference |  How to get the best ROI on Your Test Automati...Agile Mumbai 2020 Conference |  How to get the best ROI on Your Test Automati...
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...AgileNetwork
 
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...TEST Huddle
 
Software Testing
Software TestingSoftware Testing
Software TestingAdroitLogic
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Myeongseok Baek
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignVictor Rentea
 
Test Smart, not hard
Test Smart, not hardTest Smart, not hard
Test Smart, not hardDiUS
 
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015Kim Herzig
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentMeilan Ou
 
How To Tidy Up Your Test Code
How To Tidy Up Your Test CodeHow To Tidy Up Your Test Code
How To Tidy Up Your Test CodeRock Interview
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionPyxis Technologies
 
Testing 3: Types Of Tests That May Be Required
Testing 3: Types Of Tests That May Be RequiredTesting 3: Types Of Tests That May Be Required
Testing 3: Types Of Tests That May Be RequiredArleneAndrews2
 
Assessing Unit Test Quality
Assessing Unit Test QualityAssessing Unit Test Quality
Assessing Unit Test Qualityguest268ee8
 
Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Scott Keck-Warren
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And RefactoringNaresh Jain
 

Similar to Mutation Testing (20)

Making the Unstable Stable - An Intro To Testing
Making the Unstable Stable - An Intro To TestingMaking the Unstable Stable - An Intro To Testing
Making the Unstable Stable - An Intro To Testing
 
Unit testing - An introduction
Unit testing - An introductionUnit testing - An introduction
Unit testing - An introduction
 
Test Driven
Test DrivenTest Driven
Test Driven
 
Must.Kill.Mutants. Agile Testing Days 2017
Must.Kill.Mutants. Agile Testing Days 2017Must.Kill.Mutants. Agile Testing Days 2017
Must.Kill.Mutants. Agile Testing Days 2017
 
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
Agile Mumbai 2020 Conference |  How to get the best ROI on Your Test Automati...Agile Mumbai 2020 Conference |  How to get the best ROI on Your Test Automati...
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
 
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable Design
 
Test Smart, not hard
Test Smart, not hardTest Smart, not hard
Test Smart, not hard
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
How To Tidy Up Your Test Code
How To Tidy Up Your Test CodeHow To Tidy Up Your Test Code
How To Tidy Up Your Test Code
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
 
Testing 3: Types Of Tests That May Be Required
Testing 3: Types Of Tests That May Be RequiredTesting 3: Types Of Tests That May Be Required
Testing 3: Types Of Tests That May Be Required
 
Assessing Unit Test Quality
Assessing Unit Test QualityAssessing Unit Test Quality
Assessing Unit Test Quality
 
Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023
 
TestDrivenDeveloment
TestDrivenDevelomentTestDrivenDeveloment
TestDrivenDeveloment
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
 

More from Raja Nagendra Kumar

More from Raja Nagendra Kumar (9)

Novel Approach to Kill Hiring Challenges by making team replaceable with simp...
Novel Approach to Kill Hiring Challenges by making team replaceable with simp...Novel Approach to Kill Hiring Challenges by making team replaceable with simp...
Novel Approach to Kill Hiring Challenges by making team replaceable with simp...
 
RAC.pdf
RAC.pdfRAC.pdf
RAC.pdf
 
Eliminate 7 Mudas
Eliminate 7 MudasEliminate 7 Mudas
Eliminate 7 Mudas
 
IT Services 2.0 - why?
IT Services 2.0  -  why?IT Services 2.0  -  why?
IT Services 2.0 - why?
 
TejaSoft Code Audit Case Studies
TejaSoft Code Audit Case StudiesTejaSoft Code Audit Case Studies
TejaSoft Code Audit Case Studies
 
Tech Gig Webex26.03.2012
Tech Gig Webex26.03.2012Tech Gig Webex26.03.2012
Tech Gig Webex26.03.2012
 
TejaServices 2.0 Model
TejaServices 2.0 ModelTejaServices 2.0 Model
TejaServices 2.0 Model
 
Mobile Code Optimisation Services
Mobile Code Optimisation ServicesMobile Code Optimisation Services
Mobile Code Optimisation Services
 
Mobile Single Source Strategy
Mobile Single Source StrategyMobile Single Source Strategy
Mobile Single Source Strategy
 

Recently uploaded

Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 

Recently uploaded (20)

Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 

Mutation Testing

  • 1. TejaSoft Innovations Pvt. Ltd. nagendra.raja@tejasoft.com, +91-9886723872
  • 2.
  • 5.
  • 6. PURPOSE OF UNIT TESTS To know what developers have understood as method level requirment Avoid repeat manual pre-commit testing by Developers To make sure regressions are caught if the main code changed To make sure Developers get to know bugs much much before QA team can report Bring in Automation to speed up development Help Developers Identify the Unit Level Mistake (reduce debugging time) & Fix bugs with ease
  • 7. UNIT TESTING SMELLS/QUALITY GAPS • Empty Unit Tests • No Asserts • Wrong Asserts – They should have failed but pass • @Ignore and commented test code Fake Unit Tests • Even after 100% Cover Coverage, still many production or QA reported issues • New Code that conflicted past requirement should have failed past Unit tests, but it does not Tests are Not Enough • Too Much of Mocking • Flickering • Interdependencies • Long Running • Magic Numbers Complexity
  • 8.
  • 9.
  • 10. Vaccine created DEFENCE MECHANISM SHOULD KILL (Unit Tests should fail) mutated VIRUSES – then Vaccine is effective If Mutated VIRUS survives (all unit tests pass), then Unit Tests are not enough.
  • 11. WHAT DOES MUTATION MEAN? Mutation - Change Main CODE and see if Unit Tests catch (fail) What is mutation testing? Bugs, or mutants, are automatically inserted into your production code. Your tests are run for each mutant. If your tests fail then the mutant is killed. If your tests passed, the mutant survived. The higher the percentage of mutants killed, the more effective your tests are.
  • 12. HOW TO CREATE THE MUTANTS! Operator mutations About 30 different patterns like replacing + by - , * by ** and similar, but also > by >= Keyword mutations Replacing true by false , in by not in and similar Number mutations You can write things like 0b100 which is the same as 4, 0o100, which is 64, 0x100 which is 256, .12 which is 0.12 and similar. The number mutations try to capture mistakes in this area. mutmut simply adds 1 to the number. Name mutations The name mutations capture copy vs deepcopy and "" vs None . Argument mutations Replaces keyword arguments one by one from dict(a=b) to dict(aXXX=b) or_test and and_test and ↔ or String mutation Adding XX to the string Collections mutations Add Junk Elements or Remove Few elements from List or Array Value Modify Modify the VALUE of results of method calls Inject method calls Add get or setter methods multiple times in place of one call Comment the CODE Remove some code or stop the methods being called https://pitest.org/quickstart/mutators/
  • 13. 3 TYPES OF MUTATION TESTING 1. DECISION MUTATION control statements are to be changed 2. STATEMENT MUTATION developer cut and pastes a part of a code of which the outcome may be a removal of some lines 3. VALUE MUTATION values of primary parameters are modified
  • 16. ‘KATA’ MODULE – CODE WALKTHROUGH 1. Company and Employee classes 2. CompanyRunner – Explain & Execute Main – With Code Coverage 3. CompanyTest – Explain & Execute Unit Tests – With Code Coverage 4. Run PITEST kata – Explain, Execute and Show the HTML Report
  • 17. ‘FIX’ MODULE – CODE WALKTHROUGH 1. CompanyRunnerFixed – Explain & Execute Main – With Code Coverage 2. CompanyTestFixed – Explain & Execute Unit Tests – With Code Coverage 3. Run PITEST fix – Explain, Execute and Show the HTML Report 4. CompanyFixed and EmployeeFixed classes
  • 18. CODE COVERAGE VS MUTATION Code coverage doesn't tell you everything about the effectiveness of your tests. Think about it, when was the last time you saw a test without an assertion, purely to increase the code coverage Imagine a sandwich covered with chocolate paste Code coverage would tell you the bread is 80% covered with paste, does not differentiate what kind of paste is it. Mutation testing, on the other hand, would tell you it is actually chocolate paste and not... well... something else if paste is not chocolate
  • 19. REGRESSIONS VS MUTATION - TESTING 1. Regressions are unintended Since the vast majority of tests have been added due to previous bugs hence, if they find a problem, you have regressed to a previous state (in which the problem once again exists). High Failure Rates is, failure of the main code quality 2. Mutation are intended In Mutation testing framework would intentionally introduce small errors (called mutations) into your application and test failure are expected. More failures rate is high quality of Unit Testing
  • 20. REFERENCES LANGUAGE Mutation Testing Frameworks Java 1. PIT (GitHub) https://github.com/vmzakharov/mutate-test-kata - Big Thanks to @vmzakharov, as code and insights of what all I shared is his CODE only (#tejasoft https://github.com/nagkumar/mutate-test-kata only refactored it) Different Mutators: https://pitest.org/quickstart/mutators/, https://pitest.org/quickstart/commandline/ 2. Jumble - http://jumble.sourceforge.net/ 3. µJava - http://cs.gmu.edu/offutt/mujava/ 4. Jester - http://jester.sourceforge.net/ 5. Javalanche - https://github.com/david-schuler/javalanche 6. tsDetect : https://github.com/TestSmells/TestSmellDetector - Code Smells Detector C / C++ Mull C# Visualmutator, Nester JavaScript Stryker PHP Infection (formerly called humbug) Ruby Mutant Rust mutagen Swift Muter Python https://pypi.org/project/mutmut/
  • 21. MAINTAIN DISCIPLINE Do not cut corners, else end up with code and tests of “usual (IT Services)” quality
  • 22. Q&A What Gives at most Engineering Kick & Confidence? Production No Production Fires - Code Just Works Developers Unit/Mutation Tests Keep Failing QA Team Developers accept BUG as Bug Better code Each Day