Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Purpose

Unit Test Coverage shows a percentage of a source code is covered by the unit tests. It is a mix of Line coverage and Condition coverage. The metric can be also calculated also for a new code only.

How metric helps

Unit Test Coverage may be a guide for indicating a lack of coverage via Automated Testing - just because Unit Testing is the essential part of the Testing Pyramid. A trend helps to understand how a coverage is changing over time, if it is actually growing or falling and how those trends correlate with plans/investments about appropriate development efforts related to Unit Tests. Lack of coverage is typically a key obstacle for implementing the Continuous Integration and Continuous Delivery  (CI/CD) on a project.

Metric:

  • shows a percentage of a source code covered by unit tests;

  • shows quality of application;

  • shows quality of testing;

  • shows how the project is ready for implementation of CI/CD;

  • shows if the projects meets the industry quality standards;

  • highlights the risk of bugs being detected at a later stage of development;

  • helps to understand how much of your source is tested;

  • shows the quality of test suite.

TOP-5 problems metric identifies 

  1. Lack of focus on Quality

  2. Technical and Quality Debt is out of control

  3. No Test Plan or Strategy

  4. Too many defects are found during manual and / or automated testing

  5. Team misbalance (skills ratio)

Expand
titleOther
  • There are no quality standards in engineering 

  • There is no quality gate for having unit tests for new code

  • Definition of Done for features is not defined properly or missed

  • Delays in features/components delivery

  • Negative trends with other metrics e.g. Committed vs CompletedAverage velocity by sprints, etc

  • There are issues with code review

How metric works

Chart overview

Chart shows Unit Tests Coverage in % by month:

2017-10-23_15-56-43.pngImage Removed

In case if multiple Sonar projects are configured for a project in PERF, there is an option to view a summary over all them:

Image Removed

...

:

...

Calculation

Unit Test Coverage = (CT + CF + LC) / (2*B + EL),

where

  • CT = conditions that have been evaluated to 'true' at least once 

  • CF = conditions that have been evaluated to 'false' at least once

  • LC = covered lines = lines_to_cover - uncovered_lines

  • B = total number of conditions

  • EL = total number of executable lines (lines_to_cover)

RAG thresholds: Red <= 20%40%, Amber <= 50%.Unit Test Coverage for a New Code, % claculation is Identical to Unit Test Coverage but restricted to new/updated source code> 40%, Green > 80 %.

Data

...

source

Data for the metric can be collected from Sonar.

How this metric helps

Unit Test Coverage may be a guide for indicating areas which are not tested. After that it is essential to understand the reason for code not covered to prevent development issues.

 

EPMDMO-ga-entity-Perf
Include Page
EPMDMO-ga-toplevel-ASSUREEPMDMO-ga-toplevel-ASSURE
Include Page
EPMDMO-ga-entity-Perf
Insert excerpt
Integrations
Integrations
nameCopyright
nopaneltrue