Defect Density

Overview

Let’s learn about the defect density metric. A defect is any deviation in the application’s functionality not mentioned in SDLC documentation.

Defect Density Formula

Defect Density is a software testing metric calculated as the number of defects raised to the program’s size.

Formula

The formula for defect density is as follows:

Defect density = Number of defects that are uncovered / Size of the program 

Program size is usually measured in LOC ( Lines of Code ). This measures the actual lines of code in the source files, excluding comments and blank lines. The units of measurement for defect density depend on the chosen metric for the size of the program or code. The common unit is Defects Per Thousand Lines of Code (DPTL).

Defect density ( DPTL) = Number of defects that are uncovered / ( Size of the program/ 1000) 

Example

Let’s consider the following example.

The software project has 75 defects, and the program’s size is 10,000 lines of code. Based on the above formula, we can calculate the defect density metric as:

The given data is:

  • Number of defects = 75
  • Program size = 10000 LOC

Calculate the Defect density metric:

Defect Density = 75 / 10000 Defects per Line of Code

Defect Density = 0.0075 Defects per Line of Code

The same when we use Defects Per Thousand Lines of Code:

= 75 / ( 10000/1000)

= 75 / 10

= 7.5 DPTL

 

A lower defect density generally indicates better software quality. Still, the interpretation may vary based on the project’s complexity, the type of application, and the development team’s or organization’s specific goals. Regularly tracking this metric over time can help identify trends and provide insights into the effectiveness of the development and testing processes.

Software Testing Tutorials:

https://www.testingdocs.com/software-testing-tutorials/