Skip to content

Coverage Importer

Category: Importer (takes in a coverage report generated by any coverage tool - see supported formats below)

The CoverageImporter generates visualisation data from a coverage report generated by any coverage tool. The coverage report must be in one of the supported formats (see below). The CoverageImporter generates node attributes for each file in the coverage report.

MetricDescription
line_coverageThe percentage of lines covered by tests in the file.
branch_coverageThe percentage of branches covered by tests in the file.
statement_coverageThe percentage of statements covered by tests in the file.
instruction_coverageThe percentage of instructions covered by tests in the file.
complexity_coverageThe percentage of complexity covered by tests.
method_coverageThe percentage of methods covered by tests in the file.
class_coverageThe percentage of classes covered by tests.
FormatCommandDefault Report File
LCOVlcovlcov.info
JaCoCojacocojacoco.xml
Coberturacoberturacoverage.cobertura.xml
PHPUnitphpunitindex.xml
Clovercloverclover.xml
ParametersDescription
<pathToReportFile>path to the coverage report file (when specifying a folder, the importer searches for a file matching the default file name - see above)
-f, --formatspecify the format of the coverage report (see above)
-h, --helpdisplays help and exits
-nc, --not-compressedsave uncompressed output File
-o, --output-file=<outputFilePath>output File (or empty for stdout)
-klp, --keep-leading-pathsKeep full file paths, including segments before the project root directory
Usage: ccsh coverageimport -f=<format> [-h] [-nc] [-klp] [-o=<outputFile>]... <pathToReportFile>
  1. Create a coverage report with your coverage tool, e.g. with Jest
  2. Import the coverage report with the CoverageImporter
Terminal window
ccsh coverageimport lcov.info --format=lcov -o typescript_coverage.cc.json

Example Input file: lcov.info

TN:
SF:app/app.config.ts
FN:55,(anonymous_0)
FN:55,(anonymous_1)
FNF:2
FNH:0
FNDA:0,(anonymous_0)
FNDA:0,(anonymous_1)
DA:1,0
DA:2,0
DA:3,0
DA:4,0
DA:5,0
DA:6,0
DA:7,0
DA:8,0
DA:9,0
DA:10,0
DA:11,0
DA:12,0
DA:13,0
DA:14,0
DA:15,0
DA:16,0
DA:17,0
DA:18,0
DA:19,0
DA:20,0
DA:21,0
DA:22,0
DA:23,0
DA:24,0
DA:26,0
DA:55,0
LF:26
LH:0
BRF:0
BRH:0
end_of_record

Example Output file: typescript_coverage.cc.json (simplified excerpt; the real output also contains attributeTypes, attributeDescriptors and blacklist fields)

{
"projectName": "typescript_coverage",
"apiVersion": "1.5",
"nodes": [
{
"name": "root",
"type": "Folder",
"attributes": {},
"children": [
{
"name": "app",
"type": "Folder",
"attributes": {},
"children": [
{
"name": "app.config.ts",
"type": "File",
"attributes": {
"line_coverage": 0,
"branch_coverage": 0,
"statement_coverage": 0
}
}
]
}
]
}
],
"edges": []
}