Generating HTML from a merged OpenCover report throws
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
Can you please send me the unitTests.xml file? [email protected]
i will try to setup a minimal example.
@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