4.2Defect Metrics
Defect Density
What it measures: The number of defects relative to the size of the software.
Formula:
Defect Density = Number of Defects / Size of Software
Size can be measured as:
- Lines of code (KLOC = thousands of lines of code)
- Function points
- Number of user stories
- Number of modules
Example:
Release v3.2: 45 defects found in 120 KLOC
Defect Density = 45 / 120 = 0.375 defects per KLOC
Release v3.3: 32 defects found in 95 KLOC
Defect Density = 32 / 95 = 0.337 defects per KLOC
Trend: Improving (density decreased by 10%)
Why it matters: Defect density normalizes for project size. A project with 100 bugs in 500 KLOC is healthier than a project with 50 bugs in 10 KLOC.
Typical targets: 1-10 defects per KLOC for commercial software. Mission-critical systems target < 0.5 per KLOC.
Defect Escape Rate
What it measures: The percentage of defects that escape testing and reach production.
Formula:
Defect Escape Rate = (Defects Found in Production / Total Defects Found) x 100
Where Total Defects = Defects Found in Testing + Defects Found in Production
Example:
Sprint 47:
Defects found in testing: 18
Defects found in production: 2
Total: 20
Defect Escape Rate = (2 / 20) x 100 = 10%
Why it matters: This is the single most important QA effectiveness metric. It directly answers: "How good are we at catching bugs before customers see them?"
Typical targets: < 5% for mature teams. > 15% indicates significant testing gaps.
Defect Removal Efficiency (DRE)
What it measures: The percentage of defects removed before release.
Formula:
DRE = (Defects Found Before Release / Total Defects) x 100
Where Total Defects = Pre-release Defects + Post-release Defects
Example:
Release v3.2:
Defects found before release: 45
Defects found after release (within 90 days): 5
DRE = (45 / 50) x 100 = 90%
Why it matters: DRE is the inverse perspective of escape rate. A DRE of 90% means you catch 9 out of 10 bugs before they reach users. Industry leaders aim for > 95%.
Relationship to escape rate:
DRE = 100% - Defect Escape Rate