ReportGenerator icon indicating copy to clipboard operation
ReportGenerator copied to clipboard

Generating HTML from a merged OpenCover report throws

Open GrimSmiler opened this issue 8 years ago • 3 comments

I run the following commands:

OpenCover.Console.exe -register:user -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test test\UnitTests\UnitTests.csproj" -oldstyle -output:c:\opencover\unitTests.xml -coverbytest:*Test*dll -filter:"+[Server.*]* -[Server.*Test*]*"

followed by

OpenCover.Console.exe -register:user -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test test\IntegrationTests\IntegrationTests.csproj" -oldstyle -output:c:\opencover\unitTests.xml -coverbytest:*Test*dll -filter:"+[Server.*]* -[Server.*Test*]*" -mergeoutput -mergebyhash

As a result, code coverage for both tests is merged into one file unitTests.xml

If i run

.\ReportGenerator.exe -reports:C:\opencover\unitTests.xml -targetdir:C:\opencover\html

I get the following error

Loading report 'C:\opencover\unitTests.xml'
 Preprocessing report
 Initiating parser for OpenCover

Unhandled Exception: System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Palmmedia.ReportGenerator.Parser.OpenCoverParser..ctor(XContainer report)
   at Palmmedia.ReportGenerator.Parser.ParserFactory.GetParsersOfFile(String reportFile, ClassSearcherFactory classSearcherFactory, ClassSearcher globalClassSearcher)
   at Palmmedia.ReportGenerator.Parser.ParserFactory.CreateParser(IEnumerable`1 reportFiles, IEnumerable`1 sourceDirectories)
   at Palmmedia.ReportGenerator.Generator.GenerateReport(ReportConfiguration reportConfiguration)
   at Palmmedia.ReportGenerator.Program.Main(String[] args)

Anyone knows anything about it? The test projects are dotnet core 2.0 projects, same goes for the project under test.

IntegrationTests and UnitTests project both test the same project

GrimSmiler avatar Feb 21 '18 16:02 GrimSmiler

Can you please send me the unitTests.xml file? [email protected]

danielpalme avatar Feb 21 '18 21:02 danielpalme

i will try to setup a minimal example.

GrimSmiler avatar Feb 22 '18 15:02 GrimSmiler

@danielpalme wasn't able to reproduce this issue on a custom project. Sadly, i cannot share the xml file, because it contains info about the corporate code. I guess the bug can be closed. I will reopen, if i manage to reproduce the issue

GrimSmiler avatar Mar 02 '18 12:03 GrimSmiler