-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GD-133: Test Coverage isn't reported for test cases for Resharper/Rider #133
Comments
Thanks for reporting this issue, I will take a look into. |
At first, you need to enable the test code coverage in your Here is an example I used for VS Code, it generates the code coverage report. <!-- To enable code coverage -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<Format>cobertura</Format>
<CoverageFileName>coverage.cobertura.xml</CoverageFileName>
<UseSourceLink>true</UseSourceLink>
<ExcludeByFile>**/Godot.SourceGenerators/**/**.cs</ExcludeByFile>
<SingleHit>false</SingleHit>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>.*\.dll$</ModulePath>
<ModulePath>.*\.exe$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
<ModulePath>.*Moq.dll</ModulePath>
<ModulePath>.*GodotSharp.dll</ModulePath>
<ModulePath>.*GodotPlugins.dll</ModulePath>
<ModulePath>.*gdUnit4Api.dll</ModulePath>
<ModulePath>.*gdUnit4.TestAdapter.dll</ModulePath>
</Exclude>
</ModulePaths>
<Sources>
<Exclude>
<Source>.*/Godot.SourceGenerators/.*</Source>
<Source>.*/gdunit4_testadapter/.*</Source>
</Exclude>
</Sources>
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings> It should normally work also on Rider and VS. @van800 have you any idea why the .runsettings are ignored by the Rider test runner?
|
It seems this doesn't quite work with VS with Resharper either, so I suspect there's something else going on with JetBrains's tooling specifically. Unfortunately, I don't have an enterprise license of VS 2022, so I can't tell whether coverage reports normally under Microsoft's solution. I could also have misconfigured my run settings here. |
@van800 do you have knowledge of JetBrains ReSharper and code coverage? I suspect that the problem with code coverage of the executed tests is that they run in a sub-process that is started by the test runner via Godot. So I'm guessing the DLL loaded by the Godot instance is not attached to the ReSharper process. Maybe can we get in contact via Discord? |
@alicerunsonfedora it looks like it is an issue with the Jetbrains ReSharper.
I suggest doing run the coverage by this batch script as a workaround until I have found the problem with the ReSharper. runTestCoverage.bat echo "Start Test Code Coverage"
dotnet test --settings .vscode.runsettings
reportgenerator -reports:./TestResults/*/coverage.cobertura.xml -targetdir:./TestResults/coverage -reporttypes:Html_Dark -sourcedirs:./ -historydir:./TestResults/coverage/history
# opend the report in the standard browser
start "" ./TestResults/coverage\index.html here the
And you need to complete your project by adding the
And finally install the global reporting tool here is a very good documentation about https://medium.com/@nocgod/how-to-setup-your-dotnet-project-with-a-test-coverage-reporting-6ff1903f7240 |
Thanks for the advice! At the moment, I'm not too concerned on test coverage, but I figured I'd report this issue for anyone that does run into the problem with Resharper/Rider at some point. |
I am back from vacation and passed the investigation to the dotCover team. |
The used GdUnit4 version
4.3.3 (Latest Release)
The used Godot version
v4.2.2.stable.mono.official [15073afe3]
Operating System
Windows 11 Home (23H2, OS Build: 22631.3880)
Surface Pro 9, 16GB RAM, Intel Core i5 (i5-1235U)
Describe the bug
In both Rider and Visual Studio (with dotCover/Resharper), test coverage data isn't reported for nodes and other classes that the tests cover.
For example, I have an extension class in my project:
With unit tests to cover:
GdUnit picks up the tests and runs them (yay), and they show in the test explorers for both Visual Studio and Rider. However, coverage data isn't reported. It does report for other C# projects in the solution, but not the one where my game's code is specified.
In VS 2022 Community with Resharper:
In Rider 2024.1.4:
(Yes, I am aware that this is a very silly case, as I could just stick this in a library. But this happens to other tests that I've written using GdUnit).
Steps to Reproduce
Minimal reproduction project
GdUnitCoverageMinimal.zip
The text was updated successfully, but these errors were encountered: