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.

Free to start · 7-day trial on paid plans

IN DEPTH

In depth.

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 interviewers ask about this.

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

Example scenario.

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

Interview tip.

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

Frequently asked questions.

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 1,200+ QA engineers already practicing with AssertHired.

Start your free QA interview
FREE.TO.START  ·  7.DAY.TRIAL ON PAID PLANS
Written by Aston Cook, Senior QA EngineerLast updated May 2026