SlideShare une entreprise Scribd logo
1  sur  32
Intro to Mutation Testing (CON 1694)
slideshare.net/boyarsky
Twitter @jeanneboyarsky
Blog: http://www.selikoff.net
Jeanne Boyarsky
JavaOne - October 5, 2017
@jeanneboyarsky
About Me
15 years as
•Java Developer
•JUnit user
The Plan
1. About mutation testing
2. Live demo
3. A look at types of mutants
4. Profit???
@jeanneboyarsky
Why write tests?
@jeanneboyarsky
It used to
work!
How know if tests are good?
@jeanneboyarsky
If test coverage low
@jeanneboyarsky
Write more tests!
Not ready
for mutation
testing of class
If test coverage high
@jeanneboyarsky
All done!
Perfect code!
Or is it?Why is it
saying
nobody is
registered?
@jeanneboyarsky
Code Review!
@jeanneboyarsky
That’s a mutant!
@jeanneboyarsky
Too many mutants!
They’re
everywhere!
@jeanneboyarsky
PitClipse to the rescue!
@jeanneboyarsky
@jeanneboyarsky
PIT Integration Almost
JUnit 5
• Unofficial Fork:
https://github.com/tobiasstadler/pitest-junit5-plugin
• It’s coming:
https://github.com/hcoles/pitest/issues/284
https://github.com/hcoles/pitest/issues/398
@jeanneboyarsky
Easy to run
@jeanneboyarsky
The console flies by
@jeanneboyarsky
Wait, we just had 100% coverage
@jeanneboyarsky
We caught 5 mutants
@jeanneboyarsky
More detail
@jeanneboyarsky
Level up
@jeanneboyarsky
Now 23 survived
@jeanneboyarsky
Let’s try it!
@jeanneboyarsky
Observations
• JUnit tests must pass
• Fixing one may take care of more
• Found a bug
• Better tests
@jeanneboyarsky
Now with all mutators
@jeanneboyarsky
Observations
• Better tests
• Unused production code
@jeanneboyarsky
Examples of Conditional Mutants
@jeanneboyarsky
Conditionals Boundary <= vs <
Negative Conditionals <= vs >
Void Method Call Removes method calls
Examples of Math Mutants
@jeanneboyarsky
Math * vs /
Increments ++ vs --
Invert Negatives x vs -x
Examples of Other Mutants
@jeanneboyarsky
Return Values x vs x+1
Disabled by default (false
positives, duplicates or
crashes)
Constructor Calls
Inline Constants
Non Void Method Calls
Remove Conditionals
Experimental Member Variables
Switch
Tips for bigger projects
• Watch console to see if still running
• Reports on whole project – drill down/split up
• Exclude long running tests
• Experimental feature: incremental analysis
@jeanneboyarsky
Review
Code Coverage
Mutation Testing
Requirements
More info
• http://pitest.org/
• https://github.com/philglover/pitclipse
• https://dzone.com/articles/introduction-mutation
@jeanneboyarsky
@jeanneboyarsky

Contenu connexe

Similaire à 2017 JavaOne Mutation Testing Session

2016 first-champs-java-cert
2016 first-champs-java-cert2016 first-champs-java-cert
2016 first-champs-java-certJeanne Boyarsky
 
IACT-TAP New School Thinking - Prototype Workshop
IACT-TAP New School Thinking - Prototype WorkshopIACT-TAP New School Thinking - Prototype Workshop
IACT-TAP New School Thinking - Prototype WorkshopJonathan Ha
 
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...COMAQA.BY
 
Claudiu Draghia ITEM 2018
Claudiu Draghia ITEM 2018Claudiu Draghia ITEM 2018
Claudiu Draghia ITEM 2018ITEM
 
10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java Community10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java CommunityStephen Chin
 
Software development in a startup
Software development in a startupSoftware development in a startup
Software development in a startupKubide
 
Python Hype June
Python Hype JunePython Hype June
Python Hype JuneBrian Ray
 
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom GambleDev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom GambleThomas Gamble
 

Similaire à 2017 JavaOne Mutation Testing Session (13)

2016 first-champs-java-cert
2016 first-champs-java-cert2016 first-champs-java-cert
2016 first-champs-java-cert
 
IACT-TAP New School Thinking - Prototype Workshop
IACT-TAP New School Thinking - Prototype WorkshopIACT-TAP New School Thinking - Prototype Workshop
IACT-TAP New School Thinking - Prototype Workshop
 
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
 
Paving roads
Paving roadsPaving roads
Paving roads
 
Claudiu Draghia ITEM 2018
Claudiu Draghia ITEM 2018Claudiu Draghia ITEM 2018
Claudiu Draghia ITEM 2018
 
10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java Community10 Ways Everyone Can Support the Java Community
10 Ways Everyone Can Support the Java Community
 
Software development in a startup
Software development in a startupSoftware development in a startup
Software development in a startup
 
Doonish
DoonishDoonish
Doonish
 
Doonish
DoonishDoonish
Doonish
 
Git intro fajar muslim
Git intro fajar muslimGit intro fajar muslim
Git intro fajar muslim
 
Python Hype June
Python Hype JunePython Hype June
Python Hype June
 
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom GambleDev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
 
Spaceship TDD Style
Spaceship TDD StyleSpaceship TDD Style
Spaceship TDD Style
 

Plus de Jeanne Boyarsky

Pathways intro january 2018
Pathways intro   january 2018Pathways intro   january 2018
Pathways intro january 2018Jeanne Boyarsky
 
Pathways path-comparison
Pathways path-comparisonPathways path-comparison
Pathways path-comparisonJeanne Boyarsky
 
2017 stuysplash-build-tools
2017 stuysplash-build-tools2017 stuysplash-build-tools
2017 stuysplash-build-toolsJeanne Boyarsky
 
java 8 Hands on Workshop
java 8 Hands on Workshopjava 8 Hands on Workshop
java 8 Hands on WorkshopJeanne Boyarsky
 
2015 nyc-spin-collective-ownership
2015 nyc-spin-collective-ownership2015 nyc-spin-collective-ownership
2015 nyc-spin-collective-ownershipJeanne Boyarsky
 
Throw Away all the Rules: Now What Process do you Follow?
Throw Away all the Rules: Now What Process do you Follow?Throw Away all the Rules: Now What Process do you Follow?
Throw Away all the Rules: Now What Process do you Follow?Jeanne Boyarsky
 
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseGet ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseJeanne Boyarsky
 

Plus de Jeanne Boyarsky (19)

Pathways intro january 2018
Pathways intro   january 2018Pathways intro   january 2018
Pathways intro january 2018
 
Pathways path-comparison
Pathways path-comparisonPathways path-comparison
Pathways path-comparison
 
2017 stuysplash-build-tools
2017 stuysplash-build-tools2017 stuysplash-build-tools
2017 stuysplash-build-tools
 
Virtual scrum
Virtual scrumVirtual scrum
Virtual scrum
 
Ignite java-robots
Ignite java-robotsIgnite java-robots
Ignite java-robots
 
java 8 Hands on Workshop
java 8 Hands on Workshopjava 8 Hands on Workshop
java 8 Hands on Workshop
 
2017 java9-spring-days
2017 java9-spring-days2017 java9-spring-days
2017 java9-spring-days
 
Pathways overview
Pathways overviewPathways overview
Pathways overview
 
Ftc judging
Ftc judgingFtc judging
Ftc judging
 
2016 qcon-virtual-scrum
2016 qcon-virtual-scrum2016 qcon-virtual-scrum
2016 qcon-virtual-scrum
 
2016 java9-how-make-qus
2016 java9-how-make-qus2016 java9-how-make-qus
2016 java9-how-make-qus
 
2016 java9-how-make-qus
2016 java9-how-make-qus2016 java9-how-make-qus
2016 java9-how-make-qus
 
2016 java8-cert-intro
2016 java8-cert-intro2016 java8-cert-intro
2016 java8-cert-intro
 
FTC 2015-2016 Judging
FTC 2015-2016 JudgingFTC 2015-2016 Judging
FTC 2015-2016 Judging
 
2015 nyc-spin-collective-ownership
2015 nyc-spin-collective-ownership2015 nyc-spin-collective-ownership
2015 nyc-spin-collective-ownership
 
FTC Robot C to Java
FTC Robot C to JavaFTC Robot C to Java
FTC Robot C to Java
 
Frc java5-8andeclipse
Frc java5-8andeclipseFrc java5-8andeclipse
Frc java5-8andeclipse
 
Throw Away all the Rules: Now What Process do you Follow?
Throw Away all the Rules: Now What Process do you Follow?Throw Away all the Rules: Now What Process do you Follow?
Throw Away all the Rules: Now What Process do you Follow?
 
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and EclipseGet ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
Get ready for FRC 2015: Intro to Java 5 through 8 updates and Eclipse
 

Dernier

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Dernier (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

2017 JavaOne Mutation Testing Session

Notes de l'éditeur

  1. https://cdn.pixabay.com/photo/2012/05/07/05/18/bug-48020_1280.png https://pixabay.com/p-303966/?no_redirect
  2. https://cdn.pixabay.com/photo/2012/05/07/05/18/bug-48020_1280.png https://pixabay.com/p-303966/?no_redirect
  3. http://www.eclemma.org/jacoco/trunk/coverage/
  4. https://pixabay.com/p-149251/?no_redirect
  5. https://pixabay.com/p-1300226/?no_redirect
  6. http://www.publicdomainpictures.net/pictures/180000/velka/mutant-female-41.jpg
  7. http://orig01.deviantart.net/920f/f/2015/013/a/8/teenage_mutant_ninja_turtles__2003__drawing__by_n0rvv3g14n_g1rl-d8drynd.jpg
  8. Image sources: https://commons.wikimedia.org/wiki/File:Antu_netbeans-ide.svg https://commons.wikimedia.org/wiki/File:Eclipse-SVG.svg https://commons.wikimedia.org/wiki/File:IntelliJ_IDEA_Logo.svg https://ant.apache.org https://maven.apache.org http://junit.org/junit4/
  9. Run initially Add 2 assertTrue and one assertFalse on tooManyAttendees – incorrectly to show failure with failing unit tests. Wait there’s a bug. Fix assertions and see down to three mutants In cancel test assertFalse on my registration now down to two mutants Then add assertTrue on Barry’s registration and see all mutants killed
  10. Change to all mutators Run initially and note that down from 23 to 7 – our tests are better Note that the wait list logic still isn’t tested enough. Add test for jeanne and maurice cancelling with barry and sai on wait list with four asserts 4 mutants left Add test for sai not on wait list so wait list empty 2 mutants left These two are interesting as they point to unused code – isRoomForMoreAttendees always true and don’t use company name (attendee map value)
  11. https://commons.wikimedia.org/wiki/File:Online_Survey_Icon_or_logo.svg