GoEddie / SQLCover

Apache License 2.0
63 stars 53 forks source link

Publish Coverage Results in Azure DevOps #70

Open asos-eugeneniemand opened 3 years ago

asos-eugeneniemand commented 3 years ago

Describe the bug When using the Cobertura format and using the Publish Coverage Results task in ADO I get the following results in the logs

"C:\Program Files\dotnet\dotnet.exe" C:\Agent\_work\_tasks\PublishCodeCoverageResults_2a7ebc54-c13e-490e-81a5-d7561ab7cd97\1.186.0\netcoreapp2.0\ReportGenerator.dll -reports:C:\Agent\_work\101\a/**/code-coverage-report*.xml -targetdir:C:\Agent\_work\_temp\cchtml -reporttypes:HtmlInline_AzurePipelines
2021-05-20T14:44:42: Arguments
2021-05-20T14:44:42:  -reports:C:\Agent\_work\101\a/**/code-coverage-report*.xml
2021-05-20T14:44:42:  -targetdir:C:\Agent\_work\_temp\cchtml
2021-05-20T14:44:42:  -reporttypes:HtmlInline_AzurePipelines
2021-05-20T14:44:43: File '' does not exist (any more).
... (1120 more lines)
2021-05-20T14:44:44: File '' does not exist (any more).
2021-05-20T14:44:46: Writing report file 'C:\Agent\_work\_temp\cchtml\index.html'
2021-05-20T14:44:46: Report generation took 3.5 seconds
Generated code coverage html report: C:\Agent\_work\_temp\cchtml
Reading code coverage summary from 'C:\Agent\_work\101\a\_core-edw-combined-ci\core-edw-dwh-tests\DiFramework.UnitTests\code-coverage-report-datawarehouse-2021-05-20T14.44.30.xml'
Async Command Start: Publish code coverage
Publishing coverage summary data to TFS server.

When looking at the published result in ADO it has the metrics but not the file or code, see screenshot below image

I've noticed there is a field on the taks called Path to Source files with the following tooltip

Path to source files is required when coverage XML reports do not contain absolute path to source files. For e.g., JaCoCo reports do not use absolute paths and when publishing JaCoCo coverage for Java apps, the pattern would be similar to $(System.DefaultWorkingDirectory)/MyApp/src/main/java/.
This input is also needed if tests are run in a docker container. This input should point to absolute path to source files on the host. For e.g., $(System.DefaultWorkingDirectory)/MyApp/

We are not using JaCoCo so I'm not sure if the Cobertura format generated by SQLCover is incorrect or if I need to supply something in the Path to Source files field to make this work correctly

Any ideas are welcome, thanks.

@GoEddie hope you are well mate :)

ManiAc4734 commented 3 years ago

I had a similar problem, and I think it was solved by making sure that the sourcefiles and xml are in the same folder. I did this by adding a line in my powshell to save the SourceFiles , which effectivley copies these files to the specified location

$result.SaveSourceFiles($outputPath)

So I think this works becuase the source files in the code-coverage-report.xml are referenced in relation to where the code-coverage-report.xml resides. For example in your code-coverage-report.xml you should see the filename dos not contain the full path Unless there is a way to populate the full filepath to the soriginal source files