Mutation Testing: White-box method to assess test suite quality by creating small syntactic variants (mutants) of the program.

Goal: Estimate test effectiveness and potential faults. It does not verify correctness.

Key Terms:

  • Killed Mutant: Test fails → mutant detected
  • Live Mutant: All tests pass → weakness or equivalent
  • Equivalent Mutant: Behaves identically to original (undecidable problem)

2. Example & Score Calculation

Original Program:

int foo(int x, int y) {
    z = x + y;
    w = 0;
    if ((y > 0) && (z > 0)) {   // ← Line 4 (mutation target)
        w = 1;
    }
    return w;
}

Test Suite (MC/DC coverage):

Input (x, y)Expected Output
(1, 1)1
(-1, 2)1
(-1, 1)0
(1, -1)0

First-Order Mutants for Line 4:

#Mutated Line 4Change TypeResult
1if ((y > 0) || (z > 0))&& → ||Killed by test 3 (-1,1)
2if ((y >= 0) && (z > 0))>>=Live

Is Mutant 2 equivalent? No! Counterexample: (1, 0) → original returns 0, mutant returns 1.

Mutation Score:


3. Strengths & Limitations

✅ Strengths❌ Limitations
Quantitative measure of test qualityHigh computational cost
Based on fault coupling theoryEquivalent mutant problem (undecidable)
Reveals test suite weaknessesMany mutants to generate/run
// Original
int max(int a, int b) {
    if (a > b) {
        return a;
    }
    return b;
}
// Mutant: change ">" to ">="
int max(int a, int b) {
    if (a >= b) {      // ← mutated
        return a;
    }
    return b;
}