Skip to content

Calculation details

Daniel Palme edited this page Dec 21, 2024 · 9 revisions

This page explains how ReportGenerator calculates its metrics.

Assemblies: The number of assemblies.

Classes: The number of all classes in all assemblies. Nested classes are excluded.

Files: The number of distinct files containing classes.

Covered lines: The number of lines that got executed at least once. Most coverage tools don't track by line, but by sequence point. One sequence point can span several lines of code. Sequence points are mapped to the corresponding lines of code.

Uncovered lines: The number of lines that never got executed.

Coverable lines: The number of lines that can be executed. Lines containing comments or method signatures can not be executed.

Total lines: The total number of lines. The number of lines of all files are summed up. If you have files containing several classes then the result in the summary table and the sum of all classes may differ.
Reason: The summary table counts every file only once, in the detailed list files are counted several times. E.g.:

Total lines

Example:
Let's assume the code in structured in the following files:

File #Lines Classes
File 1 30 Class 1
Class 2
File 2 10 Class 3

The summary table would show Total lines of 40, since every file is counted only once.
The detailed list will show a sum of 70 lines, since File 1 is counted twice

Class1 #Lines
Class 1 30
Class 2 30
Class 3 10
Sum 70

Line coverage: Covered lines devided by Coverable lines. Only available if Coverable lines is greater than 0.

Branch coverage: Covered branches devided by Total branches. Only available if Total branches is greater than 0.
Covered branches is the number of executed branches. Total branches is the total number of branches.
Only "real" branches (<BranchPoint> in OpenCover XML) are taken into account.
OpenCover counts differently here, it counts one extra branch per method.

Method coverage: Covered methods devided by Total methods. Only available if Total methods is greater than 0.
Covered methods is the number of methods with at least one covered line. Total methods is the total number of methods.

Metrics

The metrics section in each class report contains values available in the coverage files supplied to ReportGenerator.
Each coverage format contains different metrics.

Metrics

Metrics are always displayed as they are provided in the coverage file. ReportGenerator does not (re-)calculate those values itself.
This may result in inconsistent values if you merge several coverage files. In this case the minimum/maximum value is used.
Metrics may also be inconsistent compared to the values ReportGenerator calculated itself. For instance, the branch coverage is calculated by ReportGenerator as described above. But OpenCover reports may contain a different value, see section Branch coverage above.

Clone this wiki locally