Skip to main content
Strategy & Process
DEFINITION

What is Defect Density?

Defect density is a quality metric that measures the number of confirmed defects divided by the size of the component, commonly per thousand lines of code (KLOC) or per function point or module. It is most useful for comparing modules within one codebase to find where testing effort should go, and least useful for comparing teams.

No account needed · Scored in under a minute against a senior rubric

IN DEPTH

What does Defect Density mean in practice?

Defect density normalizes raw bug counts by size so you can compare components fairly: 20 defects in a 2,000-line module is very different from 20 in a 200-line one. The formula is simply confirmed defects divided by a size unit, often defects per KLOC. Teams use it to spot fragile modules that may need refactoring or extra testing, to compare quality across releases, and as one input to release-readiness decisions.

The metric has real limitations, and naming them is the interview signal. Lines of code is a crude size proxy and is easy to game. Defect density depends heavily on how hard the code was tested, low density can mean clean code or simply weak testing. It also says nothing about severity: a module with one data-loss bug is worse than one with ten cosmetic issues at the same density. So defect density is useful as a trend and a comparison signal, not as a target to optimize directly.

It pairs well with other measures like defect escape rate and severity-weighted counts to give a fuller quality picture.

WHY IT MATTERS

Why do interviewers ask about Defect Density?

For QA lead, manager, and architect interviews, metrics questions are common. Quoting the formula is table stakes; the real signal is naming the limitations, especially that low density can mean weak testing rather than good code.

EXAMPLE

What does Defect Density look like in a real project?

A team finds module A has 8 defects in 1,000 lines (8 per KLOC) and module B has 2 in 1,000 (2 per KLOC). Before flagging A as low quality, the lead checks coverage and finds B was barely tested, its low density is a blind spot, not a strength, which is exactly why defect density is read alongside coverage.

TIP

How should you talk about Defect Density in an interview?

Give the formula, then immediately list two limitations: LOC is a weak size proxy, and low density can reflect weak testing rather than good code. Mentioning that it ignores severity rounds out a strong answer.

FAQ

Common questions about Defect Density

What is the defect density formula?

Defect density equals the number of confirmed defects divided by a size unit, most commonly defects per thousand lines of code (KLOC), but also per function point or per module.

What are the limitations of defect density?

Lines of code is a crude, gameable size proxy; low density can reflect weak testing rather than clean code; and the metric ignores severity. It is best read as a trend alongside coverage and escape rate, not optimized directly.

FREE TOOLS  /  no signup

Free QA career tools, no account needed

Instant and private, everything runs in your browser. Try them before you sign up.

EXEC.NOW

Ready to Ace Your QA Interview?

Practice explaining defect density and other key concepts with our AI interviewer.

Join 500+ QA engineers already practicing with AssertHired.

Question 1 · Automation · Mid-levellive scoring

A test passes locally but fails in CI about one run in five. Walk me through what you check first, and why.

Scored on the same four dimensions as the real thing: Technical accuracy · Coverage · Clarity · Best practices.

Rather skip ahead? Create a free account

FREE.TO.START  ·  7.DAY.TRIAL ON PAID PLANS
Written by , Senior QA Automation Engineer, 50+ QA candidate interviews conductedLast updated July 2026