Unit Test Success Rate

Purpose

Unit Test Success Rate shows a ratio of successfully passed unit tests against all unit tests (successful, failed, skipped).

How metric helps

Unit Test Success Rate shows the health of Unit Tests executed against an application code over time. For projects with mature engineering practices (like CI/CD) it is usually expected tests are always "green" i.e. a success rate is 100%, or at least fixed quickly - to ensure a healthy code being integrated down the pipeline. Otherwise, if this measure shows drops below 100% - this means broken unit tests or application code are committed by a development team into a repository. This requires a review and improvement of engineering practices / quality gates for the development team before the code is put to the repository.

How metric works

Chart overview

Chart shows Unit Test Success Rate in % - Axis Y by month -Axis X:

Calculation

Unit Test Success Rate = (Unit tests - (Unit test errors + Unit test failures + Unit test skipped)) / Unit tests * 100%,

where

Unit tests - number of all passed unit tests;

Unit test errors - number of unit tests that have failed;

Unit test failures - number of unit tests that have failed with an unexpected exception;

Unit test skipped - number of deliberately not performed unit tests.

RAG thresholds: Red < 100%, Green = 100%.

Data Source

Data for the metric can be collected from Sonar.