Skip to contents

Create a cobertura-compliant XML report following this DTD. Because there are two DTDs called coverage-04.dtd and some tools do not seem to adhere to either of them, the parser you're using may balk at the file. Please see this github discussion for context. Where covr doesn't provide a coverage metric (complexity), a zero is reported.

Usage

cobertura(x, file = "cobertura.xml")

Arguments

x

the coverage object returned from package_coverage()

file

the name of the Cobertura XML file

Value

The XML document (an xml2 document), invisibly, after writing it to file.

Details

Branch rates are only reported if branches were measured with options(covr.branch_coverage = TRUE) (see covr.branch_coverage), otherwise they are zero. Each line where an if or switch() starts then has branch="true" and a condition-coverage such as "50% (1/2)", the percentage and number of the branches of the if and switch() calls on the line that were taken. The branch rate of code without branches is one.

Note: This functionality requires the xml2 package be installed.