dotCover option IncludePerTestInfo not working from command line
I’m using dotCover 2024.1 on the command line in Windows 11, and I cannot seem to get the detailed coverage results to work. I use the following command syntax:
dotCover report /Source=Coverage.dcvr /Output=Reports\Coverage\CoverageResults.xml /ReportType=XML /IncludePerTestInfo=Method
I thought using IncludePerTestInfo=Method meant the results would show which methods are covered by which tests, but I don’t see any such information. It produces exactly the same XML output as it does if I set IncludePerTestInfo to Assembly or any other supported value. The output looks like the snippet below. What am I missing?
<Method Name="CommandToBytes(RPCDefinitions.RPCCommandArgument):byte[]" CoveredStatements="14" TotalStatements="14" CoveragePercent="100"> <OwnCoverage CoveredStatements="13" TotalStatements="13" CoveragePercent="100" /> <AnonymousMethod Name="(ushort,RPCDefinitions.RPCDataArgument):ushort" CoveredStatements="1" TotalStatements="1" CoveragePercent="100" /></Method>
Please sign in to leave a comment.
Hello David,
Thanks for contacting JetBrains support.
To clarify, snapshot files (
.dcvr) generated by the dotCover command line do not include per-test data by default. See per-test data for more information.In such a case, you need to choose XML as report type when running coverage, e.g.
dotnet-dotCover cover-dotnet --TargetWorkingDir "PrimeService.Tests" --Output coverage.xml --IncludePerTestInfo Method --ReportType XML -- test PrimeService.Tests.csprojThanks,
Tom
OK thanks for following up. I did generate the snapshot with the dotCover command line using NUnit like so:
dotCover cover /TargetExecutable=nunit-console-x86.exe /TargetArguments="MyTests.dll /framework:net-4.8" /Output="Coverage.dcvr"From what you’re saying and what I read in the documentation on per-test data, it sounds like if I’m using NUnit for my unit testing, there is no way to get per-test data unless I use the full dotCover (i.e. standalone or Visual Studio plugin) instead of the command line. Is that true? And if so, how can I get per-test data in a CI/CD pipeline if I can’t use the command line?
Hi David,
It is true that it's not supported to get per-test data from snapshots generated by dotcover command line. In your case, a possible workaround is to generate XML report directly instead of snapshot file, as shown in my previous reply.
Thanks,
Tom
Thanks Tom, but I did read your previous reply and it did not explain how to generate a coverage report using NUnit 2 as the test runner. The command syntax you provided used
cover-dotnetas the dotCover command, and the documentation for that command does not explain how to make it work with NUnit. I have NUnit 2.6.4 installed but I do not know how to configure thecover-dotnetcommand to make it use NUnit 2 (not NUnit 3+) as the test runner, since it does not have a--TargetExecutableargument as thecovercommand has. Can you explain?Hello David,
NUnit V2 test runner is not supported to include per-test data for dotCover. A workaround is to run NUnit V2 test using VS test runner.
You need to install NuGet Gallery | NUnitTestAdapter 2.3.0 first. Then you can run NUnit V2 test with “dotnet test” or “vstest.console.exe”. Please check the samples below:
dotnet test:
dotCover cover-dotnet /TargetArguments="test C:\Users\tomluo\Downloads\nunitv2-master\nunitv2-master\samples\csharp\failures\bin\Debug\cs-failures.dll" /Output="Coverage.xml" /ReportType=xml /IncludePerTestInfo=Method
(cover-dotnet uses dotnet as
TargetExecutableby default , so no need to specifyTargetExecutableargument. “test” is passed as target argument here. Under the hood it runs “dotnet test xxx.dll”)vstest.console.exe:
dotCover cover /TargetExecutable="D:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" /TargetArguments="C:\Users\tomluo\Downloads\nunitv2-master\nunitv2-master\samples\csharp\failures\bin\Debug\cs-failures.dll" /Output="Coverage.xml" /ReportType=xml /IncludePerTestInfo=Method
Thanks,
Tom