Skip to main content

mutation_kill_rate_percent

Function mutation_kill_rate_percent 

Source
pub fn mutation_kill_rate_percent(
    mutants_killed: f64,
    mutants_total: f64,
) -> Option<f64>
Expand description

Mutation kill rate as a percentage: mutants killed / mutants total × 100.

Mutation testing introduces small, artificial faults (flipping a comparison operator, changing a boundary condition) and checks whether the test suite fails against each mutated version. A high kill rate means the tests are genuinely verifying behaviour, not merely executing it; this is the check on test effectiveness itself, and coverage’s necessary complement.

§Arguments

  • mutants_killed — mutants the test suite detected (caused a failure).
  • mutants_total — total mutants generated and run against the suite.

§Returns

Some(percentage), or None when mutants_total is zero (no mutants were generated — kill rate undefined).

§Examples

use software_engineering::test_effectiveness::mutation_kill_rate_percent;

// High coverage paired with a kill rate "under 40%": tests execute
// code without meaningfully checking it.
let kill_rate = mutation_kill_rate_percent(38.0, 100.0).unwrap();
assert!(kill_rate < 40.0);
assert_eq!(mutation_kill_rate_percent(1.0, 0.0), None);