QA glossary

What is defect density?

Defect density is the number of confirmed defects found in a piece of software divided by its size, usually per thousand lines of code (KLOC) or per function point. It lets a team compare the quality of modules or releases of different sizes on the same scale.

An example from QA practice

Module A has 12 confirmed defects in 6 KLOC, a density of 2.0 per KLOC. Module B has 15 confirmed defects in 30 KLOC, a density of 0.5. Module B has more bugs in total, but module A is the one to review, because its code produces four times as many defects for its size.

What makes the number honest

The figure is easy to calculate and easy to distort. Four rules keep it meaningful:

  • Count only confirmed defects. Duplicates and rejected reports inflate it.
  • Use the same size measure every time. Lines of code and function points do not mix.
  • Compare like with like: the same period, the same test depth, the same kind of module.
  • Read it beside coverage. A low density can mean clean code, or it can mean little testing.

What it is for

Density points to where to look, not who to blame. It helps decide which module needs a code review, where extra testing pays off, and whether a release is trending better or worse than the last one.

Common questions

Does a high defect density mean the developers did poor work?

Not necessarily. Complex or heavily changed modules produce more defects, and thorough testing finds more of them. A high figure is a prompt to look at why: unclear requirements, tangled code, new staff, or simply careful testing. Treat it as a question about the module, not a verdict on people.

How do defects found by customers count in the density figure?

Count them the same way as internal ones, but keep them labelled as found after release. Mixing the two hides how well testing worked, because a module can show a low internal density when testers missed things, which defect leakage then exposes. Report both figures side by side.

Should minor defects count the same as severe ones?

For the plain density figure most teams count every confirmed defect, then add a view weighted by severity, because ten cosmetic issues and one data-loss bug are not the same risk. Show the split by severity next to the total, so the headline number cannot hide a serious defect.

How BetterQA does it

Our defect tracker, BugBoard, keeps each report with its severity and status, including won't fix, so reports that were never going to be fixed can be set apart before a density figure is calculated. Duplicates still need a person to merge them first.

Related terms

Further readingBug priority vs severity levels

Severity is the usual way to weight the defects you count.

ServiceDefect management

How we track, classify and follow defects to a fix.