and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent...
Transcript of and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent...
![Page 1: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/1.jpg)
Blank space needed here . . . just because
Making MutantsWork For
You
or how I learned to stop worryingand love equivalent mutants
![Page 2: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/2.jpg)
Blank space needed here . . . just because
Hello
![Page 3: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/3.jpg)
Blank space needed here . . . just because
Hello
?
![Page 4: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/4.jpg)
Questions
![Page 5: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/5.jpg)
How do I safely refactor mytests?
![Page 6: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/6.jpg)
How do I know if I can trust atest suite I inherited?
![Page 7: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/7.jpg)
How do I ensure the tests I’mwriting are effective?
![Page 8: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/8.jpg)
How do I know if my team iswriting effective tests?
![Page 9: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/9.jpg)
Really just one question
![Page 10: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/10.jpg)
How do I assess the quality of atest suite?
![Page 11: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/11.jpg)
Common developer answers
![Page 12: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/12.jpg)
Don’t worry - it’ll be fine
![Page 13: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/13.jpg)
That’s QA’s problem
![Page 14: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/14.jpg)
I’m a Ninja Rockstar, I know mytests are good
![Page 15: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/15.jpg)
Better answers
![Page 16: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/16.jpg)
I do TDD, I know my tests aregood.
• Are you sure?• What about the tests you didn’t write?• How do you test drive changes to your tests?• Do you write tests for your tests?• Do you write tests for the tests for your tests??
![Page 17: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/17.jpg)
I do TDD, I know my tests aregood.
• Are you sure?
• What about the tests you didn’t write?• How do you test drive changes to your tests?• Do you write tests for your tests?• Do you write tests for the tests for your tests??
![Page 18: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/18.jpg)
I do TDD, I know my tests aregood.
• Are you sure?• What about the tests you didn’t write?
• How do you test drive changes to your tests?• Do you write tests for your tests?• Do you write tests for the tests for your tests??
![Page 19: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/19.jpg)
I do TDD, I know my tests aregood.
• Are you sure?• What about the tests you didn’t write?• How do you test drive changes to your tests?
• Do you write tests for your tests?• Do you write tests for the tests for your tests??
![Page 20: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/20.jpg)
I do TDD, I know my tests aregood.
• Are you sure?• What about the tests you didn’t write?• How do you test drive changes to your tests?• Do you write tests for your tests?
• Do you write tests for the tests for your tests??
![Page 21: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/21.jpg)
I do TDD, I know my tests aregood.
• Are you sure?• What about the tests you didn’t write?• How do you test drive changes to your tests?• Do you write tests for your tests?• Do you write tests for the tests for your tests??
![Page 22: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/22.jpg)
Peer review
Good but …
• Catches problems inconsistently• Labour intensive• Slow form of feedback
![Page 23: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/23.jpg)
Peer reviewGood but …
• Catches problems inconsistently• Labour intensive• Slow form of feedback
![Page 24: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/24.jpg)
Peer reviewGood but …
• Catches problems inconsistently
• Labour intensive• Slow form of feedback
![Page 25: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/25.jpg)
Peer reviewGood but …
• Catches problems inconsistently• Labour intensive
• Slow form of feedback
![Page 26: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/26.jpg)
Peer reviewGood but …
• Catches problems inconsistently• Labour intensive• Slow form of feedback
![Page 27: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/27.jpg)
Code coverage
Most Commonly one of :-
• Line• Branch• Statement
![Page 28: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/28.jpg)
Code coverage
Most Commonly one of :-
• Line• Branch• Statement
![Page 29: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/29.jpg)
Code coverage
Most Commonly one of :-
• Line
• Branch• Statement
![Page 30: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/30.jpg)
Code coverage
Most Commonly one of :-
• Line• Branch
• Statement
![Page 31: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/31.jpg)
Code coverage
Most Commonly one of :-
• Line• Branch• Statement
![Page 32: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/32.jpg)
But there are many others
• Data• Path• Modified condition / decision• more …
![Page 33: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/33.jpg)
But there are many others
• Data
• Path• Modified condition / decision• more …
![Page 34: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/34.jpg)
But there are many others
• Data• Path
• Modified condition / decision• more …
![Page 35: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/35.jpg)
But there are many others
• Data• Path• Modified condition / decision
• more …
![Page 36: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/36.jpg)
But there are many others
• Data• Path• Modified condition / decision• more …
![Page 37: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/37.jpg)
None of these of these coveragemeasures tell you which parts ofyour code have been tested
![Page 38: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/38.jpg)
What code coverage does tell you
![Page 39: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/39.jpg)
What code coverage does tell you
![Page 40: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/40.jpg)
What code coverage does tell you
![Page 41: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/41.jpg)
What code coverage does tell you
![Page 42: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/42.jpg)
Executing code and testing codeare not the same thing
![Page 43: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/43.jpg)
![Page 44: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/44.jpg)
But most tests are written ingood faith
![Page 45: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/45.jpg)
![Page 46: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/46.jpg)
Code coverage tells you onlywhat has not been tested
![Page 47: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/47.jpg)
Lets fix that the bad faith test
![Page 48: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/48.jpg)
![Page 49: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/49.jpg)
All ok now?
![Page 50: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/50.jpg)
![Page 51: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/51.jpg)
So our answers aren’t that great
![Page 52: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/52.jpg)
Back in 1971 Richard Liptonprovided a good answer to ourquestions
decades before most people were writing unit tests.
![Page 53: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/53.jpg)
Back in 1971 Richard Liptonprovided a good answer to ourquestions
decades before most people were writing unit tests.
![Page 54: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/54.jpg)
He wrote a paper entitled “Faultdiagnosis of computer programs”
![Page 55: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/55.jpg)
Here’s Lipton’s idea
![Page 56: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/56.jpg)
If you want to know if a testsuite has properly checked somecode - introduce a bug
![Page 57: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/57.jpg)
Then see if your test suite canfind it
![Page 58: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/58.jpg)
Here’s a bug
public void count(int i) {if ( i > 10 ) {
count++;}
}
![Page 59: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/59.jpg)
Here’s a bug
public void count(int i) {if ( i > 10 ) { // changed >= to >
count++;}
}
![Page 60: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/60.jpg)
Our tests still pass
![Page 61: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/61.jpg)
Our test suite is deficient
![Page 62: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/62.jpg)
A test case is missing
@Testpublic void shouldCountIntegersOfExactlyTen() {
testee.count(10);assertEquals(1,testee.currentCount());
}
![Page 63: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/63.jpg)
Some terminology
A change such as >= to > is a mutation operator
Lots are possible
• >= to <=• >= to >• >= to =• foo.aMethod(); to //foo.aMethod();• foo.aMethod(); to foo.anotherMethod();• 0 to 1• etc etc
![Page 64: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/64.jpg)
Some terminology
A change such as >= to > is a mutation operator
Lots are possible
• >= to <=• >= to >• >= to =• foo.aMethod(); to //foo.aMethod();• foo.aMethod(); to foo.anotherMethod();• 0 to 1• etc etc
![Page 65: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/65.jpg)
Some terminology
A change such as >= to > is a mutation operator
Lots are possible
• >= to <=
• >= to >• >= to =• foo.aMethod(); to //foo.aMethod();• foo.aMethod(); to foo.anotherMethod();• 0 to 1• etc etc
![Page 66: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/66.jpg)
Some terminology
A change such as >= to > is a mutation operator
Lots are possible
• >= to <=• >= to >
• >= to =• foo.aMethod(); to //foo.aMethod();• foo.aMethod(); to foo.anotherMethod();• 0 to 1• etc etc
![Page 67: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/67.jpg)
Some terminology
A change such as >= to > is a mutation operator
Lots are possible
• >= to <=• >= to >• >= to =
• foo.aMethod(); to //foo.aMethod();• foo.aMethod(); to foo.anotherMethod();• 0 to 1• etc etc
![Page 68: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/68.jpg)
Some terminology
A change such as >= to > is a mutation operator
Lots are possible
• >= to <=• >= to >• >= to =• foo.aMethod(); to //foo.aMethod();
• foo.aMethod(); to foo.anotherMethod();• 0 to 1• etc etc
![Page 69: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/69.jpg)
Some terminology
A change such as >= to > is a mutation operator
Lots are possible
• >= to <=• >= to >• >= to =• foo.aMethod(); to //foo.aMethod();• foo.aMethod(); to foo.anotherMethod();
• 0 to 1• etc etc
![Page 70: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/70.jpg)
Some terminology
A change such as >= to > is a mutation operator
Lots are possible
• >= to <=• >= to >• >= to =• foo.aMethod(); to //foo.aMethod();• foo.aMethod(); to foo.anotherMethod();• 0 to 1
• etc etc
![Page 71: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/71.jpg)
Some terminology
A change such as >= to > is a mutation operator
Lots are possible
• >= to <=• >= to >• >= to =• foo.aMethod(); to //foo.aMethod();• foo.aMethod(); to foo.anotherMethod();• 0 to 1• etc etc
![Page 72: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/72.jpg)
Applying a mutation operator tosome code creates a mutant
We can create lots of mutants and we can do it automatically
![Page 73: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/73.jpg)
Applying a mutation operator tosome code creates a mutantWe can create lots of mutants and we can do it automatically
![Page 74: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/74.jpg)
If a mutant does not cause a testto fail it survived
![Page 75: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/75.jpg)
If a mutant does cause a test tofail it was killed
So killing is good
![Page 76: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/76.jpg)
If a mutant does cause a test tofail it was killedSo killing is good
![Page 77: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/77.jpg)
But what about this?
class Foo {int min;public void bar(int i) {
if (i < min) {min = i;
}System.out.println("" + min);
}}
![Page 78: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/78.jpg)
We can mutate it
class Foo {int min;public void bar(int i) {
if (i <= min) { // changed < to <=min = i;
}System.out.println("" + min);
}}
But it still behaves the same
![Page 79: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/79.jpg)
We can mutate it
class Foo {int min;public void bar(int i) {
if (i <= min) { // changed < to <=min = i;
}System.out.println("" + min);
}}
But it still behaves the same
![Page 80: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/80.jpg)
It is not possible to write a testthat kills this mutant
![Page 81: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/81.jpg)
The mutant is said to beequivalent
![Page 82: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/82.jpg)
Equivalent mutants areconsidered to be a problem
They need a human to examine them
We’ll talk more about them later
![Page 83: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/83.jpg)
Equivalent mutants areconsidered to be a problem
They need a human to examine them
We’ll talk more about them later
![Page 84: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/84.jpg)
Equivalent mutants areconsidered to be a problem
They need a human to examine them
We’ll talk more about them later
![Page 85: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/85.jpg)
Mutation testing highlights codethat definitely is tested
![Page 86: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/86.jpg)
It gives a very high degree ofconfidence in a test suite
![Page 87: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/87.jpg)
It can sometimes find bugs
If your program was almost correct, a mutant version might becorrect
![Page 88: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/88.jpg)
It can sometimes find bugs
If your program was almost correct, a mutant version might becorrect
![Page 89: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/89.jpg)
It effectively tests your tests
So you can refactor your tests without fear
![Page 90: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/90.jpg)
It effectively tests your tests
So you can refactor your tests without fear
![Page 91: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/91.jpg)
So what happened to this idea?
![Page 92: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/92.jpg)
1971 - Lipton’s paper
![Page 93: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/93.jpg)
![Page 94: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/94.jpg)
![Page 95: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/95.jpg)
![Page 96: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/96.jpg)
![Page 97: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/97.jpg)
![Page 98: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/98.jpg)
![Page 99: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/99.jpg)
![Page 100: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/100.jpg)
![Page 101: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/101.jpg)
![Page 102: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/102.jpg)
Just 9 short years later
The first automated tool!
![Page 103: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/103.jpg)
Just 9 short years later
The first automated tool!
![Page 104: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/104.jpg)
![Page 105: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/105.jpg)
![Page 106: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/106.jpg)
![Page 107: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/107.jpg)
![Page 108: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/108.jpg)
Lots of research papers
![Page 109: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/109.jpg)
If your test suite can findartificial bugs, can it find realones?
![Page 110: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/110.jpg)
The competent programmerhypothesis
“Programmers are generally competent enough to produce code thatis at least almost right”
![Page 111: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/111.jpg)
The competent programmerhypothesis
“Programmers are generally competent enough to produce code thatis at least almost right”
![Page 112: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/112.jpg)
The competent programmerhypothesis
“Programmers are generally competent enough to produce code thatis at least almost right”
![Page 113: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/113.jpg)
Mutation testing introducessmall changes to the code
So the mutants look like bugs from our “competent” programmer
![Page 114: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/114.jpg)
Mutation testing introducessmall changes to the code
So the mutants look like bugs from our “competent” programmer
![Page 115: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/115.jpg)
Some real bugs do look like this
But others are more complex
![Page 116: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/116.jpg)
Some real bugs do look like this
But others are more complex
![Page 117: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/117.jpg)
The coupling effect
“Tests that can distinguish a program differing from a correct one byonly simple errors can also implicitly distinguish more complexerrors”
![Page 118: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/118.jpg)
The coupling effect
“Tests that can distinguish a program differing from a correct one byonly simple errors can also implicitly distinguish more complexerrors”
![Page 119: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/119.jpg)
There is strong empiricalsupport
“The major conclusion from this investigation is that by explicitlytesting for simple faults, we are also implicitly testing for morecomplicated faults” 1
1A. Offutt. 1989. The coupling effect: fact or fiction. In Proceedings of the ACMSIGSOFT ’89 third symposium on Software testing, analysis, and verification
![Page 120: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/120.jpg)
There is strong empiricalsupport
“The major conclusion from this investigation is that by explicitlytesting for simple faults, we are also implicitly testing for morecomplicated faults” 1
1A. Offutt. 1989. The coupling effect: fact or fiction. In Proceedings of the ACMSIGSOFT ’89 third symposium on Software testing, analysis, and verification
![Page 121: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/121.jpg)
But this is just a probabilisticstatement
You will find counter examples
![Page 122: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/122.jpg)
But this is just a probabilisticstatementYou will find counter examples
![Page 123: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/123.jpg)
So if your tests find mutants,they will probably find real bugs
![Page 124: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/124.jpg)
![Page 125: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/125.jpg)
A few more academic tools
![Page 126: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/126.jpg)
![Page 127: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/127.jpg)
![Page 128: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/128.jpg)
Jester
![Page 129: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/129.jpg)
“Why just think your tests are good when you can know for sure?Sometimes Jester tells me my tests are airtight, but sometimes thechanges it finds come as a bolt out of the blue. Highlyrecommended.”
Kent Beck
![Page 130: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/130.jpg)
No-body used it
![Page 131: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/131.jpg)
Lots more research papers
![Page 132: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/132.jpg)
2018
In daily use all over the world
Folk keep talking about it at conferences
![Page 133: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/133.jpg)
2018In daily use all over the world
Folk keep talking about it at conferences
![Page 134: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/134.jpg)
2018In daily use all over the world
Folk keep talking about it at conferences
![Page 135: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/135.jpg)
High profile projects
![Page 136: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/136.jpg)
![Page 137: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/137.jpg)
![Page 138: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/138.jpg)
But mainly “normal” code
• Recruitment websites• Tractor sales• Insurance• Banking• Biotech• Media
![Page 139: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/139.jpg)
But mainly “normal” code
• Recruitment websites• Tractor sales• Insurance• Banking• Biotech• Media
![Page 140: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/140.jpg)
So what happened?
![Page 141: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/141.jpg)
40 years of research suggestedthere were two fundamentalproblems
![Page 142: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/142.jpg)
1. Too slow
![Page 143: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/143.jpg)
2. Equivalent mutants
![Page 144: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/144.jpg)
Too slow
• Need to compile the code thousands of times• Need to run the test suite thousands of times
![Page 145: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/145.jpg)
Too slow
• Need to compile the code thousands of times
• Need to run the test suite thousands of times
![Page 146: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/146.jpg)
Too slow
• Need to compile the code thousands of times• Need to run the test suite thousands of times
![Page 147: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/147.jpg)
Joda Time
A small library for dealing with dates and times.
• 68k lines of code• 70k lines of test code• Takes about 10 seconds to compile• Takes about 16 seconds to run the unit tests
![Page 148: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/148.jpg)
Joda TimeA small library for dealing with dates and times.
• 68k lines of code• 70k lines of test code• Takes about 10 seconds to compile• Takes about 16 seconds to run the unit tests
![Page 149: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/149.jpg)
Joda TimeA small library for dealing with dates and times.
• 68k lines of code
• 70k lines of test code• Takes about 10 seconds to compile• Takes about 16 seconds to run the unit tests
![Page 150: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/150.jpg)
Joda TimeA small library for dealing with dates and times.
• 68k lines of code• 70k lines of test code
• Takes about 10 seconds to compile• Takes about 16 seconds to run the unit tests
![Page 151: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/151.jpg)
Joda TimeA small library for dealing with dates and times.
• 68k lines of code• 70k lines of test code• Takes about 10 seconds to compile
• Takes about 16 seconds to run the unit tests
![Page 152: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/152.jpg)
Joda TimeA small library for dealing with dates and times.
• 68k lines of code• 70k lines of test code• Takes about 10 seconds to compile• Takes about 16 seconds to run the unit tests
![Page 153: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/153.jpg)
Lets say we have 10k mutants
![Page 154: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/154.jpg)
(100000) + (160000)compile test
![Page 155: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/155.jpg)
260000 seconds
![Page 156: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/156.jpg)
72 hours
![Page 157: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/157.jpg)
3 days!
![Page 158: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/158.jpg)
So in theory mutation testing iswildly impractical
![Page 159: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/159.jpg)
I didn’t understand this
So I tried to build a mutation testing tool
![Page 160: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/160.jpg)
I didn’t understand thisSo I tried to build a mutation testing tool
![Page 161: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/161.jpg)
Blank space needed here . . . just because
![Page 162: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/162.jpg)
Live demo time
![Page 163: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/163.jpg)
![Page 164: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/164.jpg)
A tiny assertion library fromGoogle
![Page 165: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/165.jpg)
About 3000 lines of code
![Page 166: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/166.jpg)
Takes about 3 seconds to compile
![Page 167: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/167.jpg)
Takes about 7 seconds to run thetests
![Page 168: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/168.jpg)
Has about 90% line coverage
![Page 169: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/169.jpg)
If we generated a modest 700mutants
![Page 170: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/170.jpg)
Would take about 2 hours
![Page 171: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/171.jpg)
Lets try it
![Page 172: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/172.jpg)
mvn -Ppitest test
![Page 173: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/173.jpg)
So why didn’t that take 2 hours?
![Page 174: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/174.jpg)
Lots of reasons
![Page 175: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/175.jpg)
It runs in parallel
Mutation testing is embarrassingly parallelisable
Most machines these days have at least 2 cores
2 cores = half the time
![Page 176: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/176.jpg)
It runs in parallel
Mutation testing is embarrassingly parallelisable
Most machines these days have at least 2 cores
2 cores = half the time
![Page 177: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/177.jpg)
It runs in parallel
Mutation testing is embarrassingly parallelisable
Most machines these days have at least 2 cores
2 cores = half the time
![Page 178: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/178.jpg)
It runs in parallel
Mutation testing is embarrassingly parallelisable
Most machines these days have at least 2 cores
2 cores = half the time
![Page 179: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/179.jpg)
No compilation cycles
Mutants created by bytecode manipulation
Can generate hundreds of thousands in <1 second
![Page 180: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/180.jpg)
No compilation cycles
Mutants created by bytecode manipulation
Can generate hundreds of thousands in <1 second
![Page 181: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/181.jpg)
No compilation cycles
Mutants created by bytecode manipulation
Can generate hundreds of thousands in <1 second
![Page 182: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/182.jpg)
Test prioritisation
Run the cheap tests first, the expensive ones later
stop when one fails
![Page 183: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/183.jpg)
Test prioritisation
Run the cheap tests first, the expensive ones later
stop when one fails
![Page 184: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/184.jpg)
Test prioritisation
Run the cheap tests first, the expensive ones later
stop when one fails
![Page 185: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/185.jpg)
Test selectionPitest gathers per test line coverage data
Tests are only run against a mutant if they exercise the mutated lineof code
![Page 186: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/186.jpg)
Test selectionPitest gathers per test line coverage data
Tests are only run against a mutant if they exercise the mutated lineof code
![Page 187: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/187.jpg)
This makes a huge difference
![Page 188: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/188.jpg)
![Page 189: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/189.jpg)
shouldNotCountIntegersBelowTen
![Page 190: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/190.jpg)
shouldCountIntegersAboveTen
shouldNotCountIntegersBelowTen
![Page 191: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/191.jpg)
shouldCountIntegersAboveTen
shouldNotCountIntegersBelowTen
shouldStartWithEmptyCount
![Page 192: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/192.jpg)
>
• We will only run 2 tests for the mutation on line 5• The mutation will survive as we’re missing an effective test case
![Page 193: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/193.jpg)
>
• We will only run 2 tests for the mutation on line 5
• The mutation will survive as we’re missing an effective test case
![Page 194: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/194.jpg)
>
• We will only run 2 tests for the mutation on line 5• The mutation will survive as we’re missing an effective test case
![Page 195: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/195.jpg)
//
• We will run only 1 test for the mutation on line 6• The mutation will be killed
![Page 196: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/196.jpg)
//
• We will run only 1 test for the mutation on line 6
• The mutation will be killed
![Page 197: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/197.jpg)
//
• We will run only 1 test for the mutation on line 6• The mutation will be killed
![Page 198: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/198.jpg)
1
• We will run no tests for the mutation on line 11• The mutation will be instantly marked as survived• This is makes a huge different
![Page 199: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/199.jpg)
1
• We will run no tests for the mutation on line 11
• The mutation will be instantly marked as survived• This is makes a huge different
![Page 200: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/200.jpg)
1
• We will run no tests for the mutation on line 11• The mutation will be instantly marked as survived
• This is makes a huge different
![Page 201: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/201.jpg)
1
• We will run no tests for the mutation on line 11• The mutation will be instantly marked as survived• This is makes a huge different
![Page 202: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/202.jpg)
To analyse JodaTime
• 8 minutes on cheap dual core laptop• 3 minutes on a quad core
That’s over 1000 times faster than early systems
![Page 203: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/203.jpg)
To analyse JodaTime
• 8 minutes on cheap dual core laptop
• 3 minutes on a quad core
That’s over 1000 times faster than early systems
![Page 204: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/204.jpg)
To analyse JodaTime
• 8 minutes on cheap dual core laptop• 3 minutes on a quad core
That’s over 1000 times faster than early systems
![Page 205: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/205.jpg)
To analyse JodaTime
• 8 minutes on cheap dual core laptop• 3 minutes on a quad core
That’s over 1000 times faster than early systems
![Page 206: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/206.jpg)
To analyse JodaTime
• 8 minutes on cheap dual core laptop• 3 minutes on a quad core
That’s over 1000 times faster than early systems
![Page 207: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/207.jpg)
But what about big codebases?
![Page 208: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/208.jpg)
Turns out size doesn’t matter
![Page 209: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/209.jpg)
To understand why we need totalk about what mutation testingis useful for
and how to use it
![Page 210: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/210.jpg)
To understand why we need totalk about what mutation testingis useful forand how to use it
![Page 211: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/211.jpg)
A lot of the research assumed ithad to work like this
![Page 212: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/212.jpg)
Write abunch of code
and tests
Pass it to a QAteam to mutation test
![Page 213: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/213.jpg)
Many developers assume youuse it like this
![Page 214: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/214.jpg)
Write abunch of code
and tests
![Page 215: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/215.jpg)
Write abunch of code
and tests
Mutation test overnight on a server
![Page 216: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/216.jpg)
Write abunch of code
and tests
Brag about the size of your metric
Mutation test overnight on a server
![Page 217: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/217.jpg)
But I only ever use it like this
![Page 218: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/218.jpg)
Write afailingtest
Make thetest pass
Refactor Mutation test affected code
![Page 219: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/219.jpg)
Or sometimes
![Page 220: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/220.jpg)
Spike outcode
Write tests
fix the messMutation test affected code
![Page 221: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/221.jpg)
I’d be too scared to do thiswithout mutation testing
![Page 222: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/222.jpg)
I only have to analyse a smallslice of the code
![Page 223: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/223.jpg)
It doesn’t matter how big thecodebase is
![Page 224: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/224.jpg)
The slice is always small
![Page 225: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/225.jpg)
Pitest integrates with versioncontrol
But often I just target it at a certain package
![Page 226: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/226.jpg)
Pitest integrates with versioncontrolBut often I just target it at a certain package
![Page 227: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/227.jpg)
Mutation testing is a powerfultool
![Page 228: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/228.jpg)
I don’t use it as a metric
![Page 229: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/229.jpg)
I don’t care what the codecoverage of a project is
![Page 230: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/230.jpg)
I don’t care what the mutationscore for a project is
![Page 231: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/231.jpg)
I care about the feedback it givesme
![Page 232: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/232.jpg)
And the actions it prompts me totake
![Page 233: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/233.jpg)
Equivalent mutants
![Page 234: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/234.jpg)
Research suggests it takes 15minutes to assess if a mutant isequivalent
![Page 235: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/235.jpg)
But this assumes that the personassessing hasn’t just written thecode
It’s much less effort as part of a development feedback loop
![Page 236: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/236.jpg)
But this assumes that the personassessing hasn’t just written thecodeIt’s much less effort as part of a development feedback loop
![Page 237: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/237.jpg)
Equivalent mutants are aproblem for a test strengthmetric
![Page 238: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/238.jpg)
But they can provide usefulinformation for a developer
They’re a side benefit
![Page 239: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/239.jpg)
But they can provide usefulinformation for a developer
They’re a side benefit
![Page 240: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/240.jpg)
If a mutant survives I do one ofthree things
![Page 241: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/241.jpg)
Add a test
Or sometimes fix a buggy test
![Page 242: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/242.jpg)
Add a testOr sometimes fix a buggy test
![Page 243: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/243.jpg)
Delete some code
![Page 244: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/244.jpg)
Re-express some code
Or sometimes change its behaviour
![Page 245: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/245.jpg)
Re-express some code
Or sometimes change its behaviour
![Page 246: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/246.jpg)
Some examples
![Page 247: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/247.jpg)
public void someLogic(int i) {if (i <= 100) {
throw new IllegalArgumentException();}
if (i > 100) {doSomething();
}}
![Page 248: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/248.jpg)
public void someLogic(int i) {if (i <= 100) {
throw new IllegalArgumentException();}
if (i >= 100) { // mutated > to >=doSomething();
}}
i can never be 100 at this point
So the mutant is equivalent
![Page 249: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/249.jpg)
public void someLogic(int i) {if (i <= 100) {
throw new IllegalArgumentException();}
if (i >= 100) { // mutated > to >=doSomething();
}}
i can never be 100 at this point
So the mutant is equivalent
![Page 250: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/250.jpg)
public void someLogic(int i) {if (i <= 100) {
throw new IllegalArgumentException();}
if (i >= 100) { // mutated > to >=doSomething();
}}
i can never be 100 at this point
So the mutant is equivalent
![Page 251: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/251.jpg)
The code is redundant
![Page 252: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/252.jpg)
public void someLogic(int i) {if (i <= 100) {
throw new IllegalArgumentException();}
doSomething();}
Functionally equivalent but there’s less of it
![Page 253: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/253.jpg)
public void someLogic(int i) {if (i <= 100) {
throw new IllegalArgumentException();}
doSomething();}
Functionally equivalent but there’s less of it
![Page 254: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/254.jpg)
Mutation testing is really good athighlighting redundant code
![Page 255: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/255.jpg)
class Foo {int min;public void bar(int i) {
if (i < min) {min = i;
}System.out.println("" + min);
}}
![Page 256: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/256.jpg)
class Foo {int min;public void bar(int i) {
if (i <= min) { // mutate < to <=min = i;
}System.out.println("" + min);
}}
![Page 257: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/257.jpg)
A classic logically equivalentmutant
We can make it go away
![Page 258: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/258.jpg)
A classic logically equivalentmutantWe can make it go away
![Page 259: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/259.jpg)
class Foo {int min;public void bar(int i) {
min = Math.min(i, min);System.out.println("" + min);
}}
The code now expresses its intent
![Page 260: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/260.jpg)
class Foo {int min;public void bar(int i) {
min = Math.min(i, min);System.out.println("" + min);
}}
The code now expresses its intent
![Page 261: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/261.jpg)
So sometimes equivalent mutantsprompt us to improve the code
![Page 262: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/262.jpg)
Mutation testing creates pressureto
• Reduce the amount of code• Reduce the amount of duplication
![Page 263: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/263.jpg)
Mutation testing creates pressureto
• Reduce the amount of code
• Reduce the amount of duplication
![Page 264: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/264.jpg)
Mutation testing creates pressureto
• Reduce the amount of code• Reduce the amount of duplication
![Page 265: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/265.jpg)
Many equivalent mutants affectonly performance
(performance is not a concern of unit testing)
![Page 266: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/266.jpg)
Many equivalent mutants affectonly performance
(performance is not a concern of unit testing)
![Page 267: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/267.jpg)
Is it a premature optimisation?
• Yes - delete the code• No - ignore the mutant
![Page 268: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/268.jpg)
Is it a premature optimisation?
• Yes - delete the code
• No - ignore the mutant
![Page 269: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/269.jpg)
Is it a premature optimisation?
• Yes - delete the code• No - ignore the mutant
![Page 270: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/270.jpg)
What did pitest find in GoogleTruth?
![Page 271: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/271.jpg)
Some classic test errors
![Page 272: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/272.jpg)
PrimitiveIntSubjectArray
![Page 273: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/273.jpg)
PrimitiveIntSubjectArray
![Page 274: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/274.jpg)
Mutant is covered by at least onetest
![Page 275: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/275.jpg)
Mutant is covered by at least onetest
![Page 276: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/276.jpg)
An equivalent mutation
![Page 277: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/277.jpg)
PrimitiveDoubleArraySubject
![Page 278: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/278.jpg)
PrimitiveDoubleArraySubject
![Page 279: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/279.jpg)
PrimitiveDoubleArraySubject
![Page 280: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/280.jpg)
Performance isn’t unit testable
Optimisation makes sense in this case
![Page 281: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/281.jpg)
Performance isn’t unit testableOptimisation makes sense in this case
![Page 282: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/282.jpg)
But wouldn’t it be better if themessage was?
“%s unexpectedly equal to %s (in fact they are the same)”
![Page 283: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/283.jpg)
But wouldn’t it be better if themessage was?
“%s unexpectedly equal to %s (in fact they are the same)”
![Page 284: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/284.jpg)
So perhaps the equivalentmutation highlighted a betterbehaviour
![Page 285: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/285.jpg)
What if we think the behaviouris perfect the way it is?
![Page 286: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/286.jpg)
![Page 287: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/287.jpg)
![Page 288: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/288.jpg)
In many code bases you willencounter no equivalent mutants
![Page 289: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/289.jpg)
Seems to depend on the domainand code style
![Page 290: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/290.jpg)
When not to mutation test
![Page 291: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/291.jpg)
1. When your tests are really bad
![Page 292: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/292.jpg)
Mutation testing relies on testsbeing deterministic
• Same result when run a million times• Same result when run in a different order• Same result when run in parallel
![Page 293: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/293.jpg)
Mutation testing relies on testsbeing deterministic
• Same result when run a million times
• Same result when run in a different order• Same result when run in parallel
![Page 294: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/294.jpg)
Mutation testing relies on testsbeing deterministic
• Same result when run a million times• Same result when run in a different order
• Same result when run in parallel
![Page 295: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/295.jpg)
Mutation testing relies on testsbeing deterministic
• Same result when run a million times• Same result when run in a different order• Same result when run in parallel
![Page 296: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/296.jpg)
Everyone thinks their tests aredeterministic
But many bugs reported against pitest are due to bad tests
And bad code with singletons and mutable global state
![Page 297: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/297.jpg)
Everyone thinks their tests aredeterministicBut many bugs reported against pitest are due to bad tests
And bad code with singletons and mutable global state
![Page 298: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/298.jpg)
Everyone thinks their tests aredeterministicBut many bugs reported against pitest are due to bad tests
And bad code with singletons and mutable global state
![Page 299: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/299.jpg)
Pitest needs unit tests
• Code runs in same jvm as tests• Fast enough to run many times
![Page 300: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/300.jpg)
Pitest needs unit tests
• Code runs in same jvm as tests
• Fast enough to run many times
![Page 301: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/301.jpg)
Pitest needs unit tests
• Code runs in same jvm as tests• Fast enough to run many times
![Page 302: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/302.jpg)
2. When your code does scarythings
if (!safetyFlag) {launchMissiles();
}
![Page 303: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/303.jpg)
2. When your code does scarythings
if (!safetyFlag) {launchMissiles();
}
![Page 304: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/304.jpg)
Conclusions
Mutation testing is a powerfultechnique
![Page 305: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/305.jpg)
It finds missing test cases
![Page 306: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/306.jpg)
It finds buggy tests
![Page 307: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/307.jpg)
It provides a safety net whilerefactoring your tests
![Page 308: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/308.jpg)
It highlights redundant code
![Page 309: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/309.jpg)
It can highlight code smells
![Page 310: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/310.jpg)
Run it as you develop
Not some time later
![Page 311: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/311.jpg)
Run it as you develop
Not some time later
![Page 312: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/312.jpg)
Remember it’s a tool
Not a number you need to make go up
Or a stick to beat people with
![Page 313: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/313.jpg)
Remember it’s a toolNot a number you need to make go up
Or a stick to beat people with
![Page 314: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/314.jpg)
Remember it’s a toolNot a number you need to make go up
Or a stick to beat people with
![Page 315: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/315.jpg)
Other languages
• Ruby - Mutant• PHP - Humbug (now Infection)• Java - Pitest (could also try Major)• Kotlin - Pitest (with caveats)• Python - Cosmic Ray• LLVM (C, C++, Swift) - Mull• Javascript - Stryker• C# - Fettle
![Page 316: and love equivalent mutants - STAMP€¦ · and love or how I learned to stop equivalent mutantsworrying. Blank space needed here . . . just because Hello. Blank space needed here](https://reader036.fdocuments.in/reader036/viewer/2022090605/6059c2f5bf68ea32736297bc/html5/thumbnails/316.jpg)
@0hjc
http://pitest.orgturns out
it's me that guards the guards