The PowerShell unit-testing framework Pester can generate coverage reports in the JaCoCO xml format.
The file seems fine, but Codecov reports: “There was an error processing coverage reports.”
Hi @Farwaykorse and apologies for the delay, would you be able to re-run the Appveyor build? I wanted to take a look at a recent build to see if I can debug the issue.
I’m curios if the file have the wrong format in some way. Do you have a known to work JaCoCo file I can use as a comparison to see if the file that is generated in my pipeline is wrong?
I got it to parse and comment on the PR. Yay! Until a solution is in Pester the workaround I’m using is a PowerShell task that updates the ‘mb’ and ‘cb’ attribute to “0” (zero). I’m uncertain if Pester (PowerShell) can see branches. Also, the method Save() creates the file using the encoding UTF-8 with BOM and Codecov “parser” does not like that.
$xml = Select-Xml -Path './output/testResults/CodeCov*.xml' -XPath '.'
$nodes = $xml.Node.SelectNodes("/report/package/sourcefile/line");
foreach ($node in $nodes)
{
$node.SetAttribute('mb', 0)
$node.SetAttribute('cb', 0)
}
$xml.Node.Save("./output/testResults/JaCoCo_coverage.xml")
# This changes the encoding on the file to UTF-8 without BOM.
$fileContent = Get-Content -Path './output/testResults/JaCoCo_coverage.xml' -Encoding 'Unicode' -Raw
$fileContent | Out-File -FilePath './output/testResults/JaCoCo_coverage.xml' -Encoding 'ascii'
That’s for the sharing the update! I’m sure this will help others running into these issues. Did you happen to create an issue against Pester we can keep an eye on?
Pester 4.10 has been released that solves this issue by providing the missing attributes and also adds a parameter to set the encoding the JaCoCo XML is saved with (default on Windows is UTF8 with BOM which does not work with Codecov.io), I use the 'ascii' encoding which works.