I have generated code coverage report using clover, and then try to run reportgenerator to generate report and I got this error. Do you have any idea about this?
Actually I do the same thing with my other projects, and it working fine.
Can you share your coverage file?
Thanks for your email. Will have a look as soon as possible.
New release 4.6.2 fixes this issue.
Thanks @danielpalme
@danielpalme, I have the same kind of issue with opencover.xml.
Will have a look at the end of august
@MikaelFerland
Can you share a sample OpenCover file?
@MikaelFerland:
Thanks for sharing your OpenCover file.
The file seems to be "invalid". It contains <TrackedMethod /> elements. Each element should have a unique uid attribute. This is not the case with this file.
Which tool are you using to generate the file (e.g. OpenCover, coverlet, altcover)?
Next release of ReportGenerator will just ignore TrackedMethods if uids are not unique:
https://www.nuget.org/packages/ReportGenerator/4.6.5
I'm using OpenCover.
I guess that OpenCover is no longer actively maintained (@sawilde?!)
But at least ReportGenerator can handle your files now.
I'm getting the same thing when using coverlet on the test runner, with output format cobertuna-- and -- when i specify a report type.
If I leave off specifying a report type ( reportypes), it works. Not a very pretty report compared to what I see in the documentation pages - seems to be missing things in terms of look and feel. Trying any combination or singular type of report causes this (well 'HtmlInline' says it spit out an index.html, but PublishCodeCoverageResults fails with a warning saying no reports found).
But - like i said - if I leave off that property in the pipeline task, it runs.
Setup is below, using a dummy project with simple tests. Tests are run in docker, and results are copied out to pipeline.
dotnet test PipelineRuns.Tests/PipelineRuns.Tests.csproj \
--results-directory /testresults \
--logger "trx;LogFileName=/testresults/unit-tests.trx" \
/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura \
/p:CoverletOutput=/testresults/coverage/BuildUnitTests.cobertura.xml \
/p:Exclude="[xunit.*]*%2c[StackExchange.*]*"
The pipeline section:
- task: reportgenerator@4
inputs:
reports: '$(Pipeline.Workspace)/testresults/coverage/*.cobertura.xml'
targetdir: '$(Build.SourcesDirectory)/CoverageResults'
sourcedirs: '$(System.DefaultWorkingDirectory)/PipelineRuns'
reporttypes: 'HTMLInline;HtmlInline_AzurePipelines;HtmlInline_AzurePipelines_Dark' # remove this and it works
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/CoverageResults/Cobertura.xml'
pathToSources: $(System.DefaultWorkingDirectory)/PipelineRuns
2020-09-07T12:58:49.1104772Z ##[section]Starting: reportgenerator
2020-09-07T12:58:49.1111066Z ==============================================================================
2020-09-07T12:58:49.1111332Z Task : ReportGenerator
2020-09-07T12:58:49.1111764Z Description : ReportGenerator converts coverage reports generated by OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.
2020-09-07T12:58:49.1112143Z Version : 4.6.6
2020-09-07T12:58:49.1112331Z Author : Palmmedia
2020-09-07T12:58:49.1112597Z Help : [More Information](https://github.com/danielpalme/ReportGenerator)
2020-09-07T12:58:49.1112901Z ==============================================================================
2020-09-07T12:58:49.2451000Z [command]/usr/bin/dotnet /home/vsts/work/_tasks/reportgenerator_be803a55-9253-4895-a525-be570d86f161/4.6.6/tools/netcoreapp2.1/ReportGenerator.dll -reports:/home/vsts/work/1/testresults/coverage/*.cobertura.xml -targetdir:/home/vsts/work/1/s/CoverageResults -reporttypes:HTMLInline;HtmlInline_AzurePipelines;HtmlInline_AzurePipelines_Dark -sourcedirs:/home/vsts/work/1/s/PipelineRuns -historydir: -plugins: -assemblyfilters:+* -classfilters:+* -filefilters:+* -verbosity:Info -title: -tag:fifthRun#6_#16295
2020-09-07T12:58:50.0257037Z 2020-09-07T12:58:50: Error during rendering report for class 'PipelineRuns.ExternalModule' (Report type: 'HtmlInline_AzurePipelines'): An item with the same key has already been added. Key: PipelineRuns_PipelineRuns.ExternalModule
2020-09-07T12:58:50.0270556Z 2020-09-07T12:58:50: Error during rendering report for class 'PipelineRuns.ExternalModule' (Report type: 'HtmlInline_AzurePipelines_Dark'): Collection was modified; enumeration operation may not execute.
2020-09-07T12:58:50.0597450Z 2020-09-07T12:58:50: Error during rendering report for class 'PipelineRuns.JasonClass' (Report type: 'HtmlInline_AzurePipelines'): Collection was modified; enumeration operation may not execute.
2020-09-07T12:58:50.0811652Z 2020-09-07T12:58:50: Writing report file '/home/vsts/work/1/s/CoverageResults/index.html'
2020-09-07T12:58:50.1417338Z 2020-09-07T12:58:50: Writing report file '/home/vsts/work/1/s/CoverageResults/index.html'
2020-09-07T12:58:50.1478090Z 2020-09-07T12:58:50: Writing report file '/home/vsts/work/1/s/CoverageResults/index.html'
2020-09-07T12:58:50.1526568Z 2020-09-07T12:58:50: Report generation took 0.3 seconds
2020-09-07T12:58:50.1582332Z
2020-09-07T12:58:50.1666948Z ##[section]Finishing: reportgenerator
@jason-e-gross
Please use the following YAML for light theme:
- task: reportgenerator@4
inputs:
reports: '$(Pipeline.Workspace)/testresults/coverage/*.cobertura.xml'
targetdir: '$(Build.SourcesDirectory)/CoverageResults'
sourcedirs: '$(System.DefaultWorkingDirectory)/PipelineRuns'
reporttypes: 'HtmlInline_AzurePipelines;Cobertura'
Or this for a dark theme:
- task: reportgenerator@4
inputs:
reports: '$(Pipeline.Workspace)/testresults/coverage/*.cobertura.xml'
targetdir: '$(Build.SourcesDirectory)/CoverageResults'
sourcedirs: '$(System.DefaultWorkingDirectory)/PipelineRuns'
reporttypes: 'HtmlInline_AzurePipelines_Dark;Cobertura'
Specifying several HTML report types is not useful. You will get an unpredictable result!