Measure the strength of a test suite for StudyBuddy's pass rule:
A student passes if
score >= 60andattendance >= 75(percent), or ifscore >= 90(excellent score, whatever the attendance).
The original implementation is (score >= 60 && attendance >= 75) || score >= 90. Your program contains the original and these six mutants:
| Mutant | Code |
|---|---|
| M1 | (score > 60 && attendance >= 75) || score >= 90 |
| M2 | (score >= 60 && attendance > 75) || score >= 90 |
| M3 | (score >= 60 || attendance >= 75) || score >= 90 |
| M4 | (score >= 60 && attendance >= 75) || score > 90 |
| M5 | (score >= 60 && attendance >= 75) |
| M6 | (score >= 60 && attendance >= 75) && score >= 90 |
Input: test cases, one per line: score attendance expected (expected is true/false), until the end of input.
- First run every test on the original. If a test fails on the original, print
Invalid test: score attendance expectedfor each such test and stop — a test that fails on correct code is itself wrong. - Otherwise, for each mutant print
M1: KILLED by test k(k = number of the first failing test, 1-based) orM1: SURVIVED. - Print
Mutation score: killed/6 (P%)withP = killed * 100 / 6(integer division), and, if any mutant survived,Add tests for: M2, M4(the survivors).
Input:
70 80 true
50 90 false
95 10 true
Output:
M1: SURVIVED
M2: SURVIVED
M3: KILLED by test 2
M4: SURVIVED
M5: KILLED by test 3
M6: KILLED by test 1
Mutation score: 3/6 (50%)
Add tests for: M1, M2, M4