330 likes | 428 Views
Join Jeanne Boyarsky for an insightful session on mutation testing, exploring its benefits, live demo, mutator examples, and tips for larger projects. Discover how mutation testing complements code coverage, enabling better test quality and bug detection. Learn about the PitClipse tool integration and JUnit 5 fork for seamless execution. Elevate your testing prowess and ensure robust Java development practices with this essential guide.
E N D
Intro to Mutation Testing Jeanne Boyarsky Oracle Code NYC – March 8, 2018 speakerdeck.com/boyarsky Twitter @jeanneboyarsky Blog: http://www.selikoff.net
About Me 15 years as • Java Developer • JUnit user @jeanneboyarsky
The Plan • About mutation testing • Live demo • A look at types of mutants • Profit??? @jeanneboyarsky
Why write tests? It used to work! @jeanneboyarsky
How know if tests are good? @jeanneboyarsky
If test coverage low Write more tests! Not ready for mutation testing of class @jeanneboyarsky
If test coverage high All done! Perfect code! @jeanneboyarsky
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
Almost PIT Integration @jeanneboyarsky
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! Demo @jeanneboyarsky
Observations • JUnit tests must pass • Fixing one may take care of more • Found a bug • Better tests @jeanneboyarsky
Now with all mutators Demo @jeanneboyarsky
Observations • Better tests • Unused production code @jeanneboyarsky
Examples of Conditional Mutants @jeanneboyarsky
Examples of Math Mutants @jeanneboyarsky
Examples of Other Mutants @jeanneboyarsky
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 Requirements Mutation Testing Code Coverage
More info • http://pitest.org/ • https://github.com/philglover/pitclipse • https://dzone.com/articles/introduction-mutation @jeanneboyarsky
??? @jeanneboyarsky