Skip to content

Fix the valid/covered lines and branches in the cobertura report #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class CoberturaXmlWriter(sourceDirectories: Seq[File], outputDir: File) extends
def this (baseDir: File, outputDir: File) {
this(Seq(baseDir), outputDir)
}

def format(double: Double): String = "%.2f".format(double)

def write(coverage: Coverage): Unit = {
val file = new File(outputDir, "cobertura.xml")
IOUtils.writeToFile(file, "<?xml version=\"1.0\"?>\n<!DOCTYPE coverage SYSTEM \"https://raw.githubusercontent.com/cobertura/cobertura/master/cobertura/src/site/htdocs/xml/coverage-04.dtd\">\n" +
IOUtils.writeToFile(file, "<?xml version=\"1.0\"?>\n<!DOCTYPE coverage SYSTEM \"https://raw.githubusercontent.com/cobertura/cobertura/master/cobertura/src/site/htdocs/xml/coverage-04.dtd\">\n" +
new PrettyPrinter(120, 4).format(xml(coverage)))
}

Expand Down Expand Up @@ -75,10 +75,10 @@ class CoberturaXmlWriter(sourceDirectories: Seq[File], outputDir: File) extends

def xml(coverage: Coverage): Node = {
<coverage line-rate={format(coverage.statementCoverage)}
lines-covered={coverage.statementCount.toString}
lines-valid={coverage.invokedStatementCount.toString}
branches-covered={coverage.branchCount.toString}
branches-valid={coverage.invokedBranchesCount.toString}
lines-valid={coverage.statementCount.toString}
lines-covered={coverage.invokedStatementCount.toString}
branches-valid={coverage.branchCount.toString}
branches-covered={coverage.invokedBranchesCount.toString}
branch-rate={format(coverage.branchCoverage)}
complexity="0"
version="1.0"
Expand Down