dotCover never works in Rider?

It was tricky getting unit tests to work in general, but now that they work, coverage doesn't work at all. Even the tests themselves are uncovered despite passing.

This is .NET Core 3.1 (x86), and I'm trying to use MSTest. It's possible that I'm not referencing MSTest properly. My test project .csproj has these lines to load MSTest:

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
</ItemGroup>


I don't have any other package references in the test project. It uses `Sdk="Microsoft.NET.Sdk"` and there are no other lines that are specifically for test projects.

The tests run, but when I use coverage, I get 100% uncovered, even the tests that ran and pass are uncovered.

Thanks

6 comments
Comment actions Permalink

Hello Dave,

Please enable Traces for dotCover in Help | Diagnostic Tools | Trace Scenarios, reproduce the issue and collect the logs via Help | Collect logs. Resulting log bundle attach with a new issue on our bug tracker. It will help us to take a closer look at your issue and system Thank you in advance!

0
Comment actions Permalink

I found that after converting my project from .NET Core 3.1 to .NET 4.0 that dotCover now works for that project. It still does not work for other .NET Core 3.1 projects though.

Is there anything in particular in the log that is more important, like the idea.log file or something? I can see various IndexOutOfRangeExceptions and some others in idea.log. It looks like if I share the entire log bundle that I will be giving you my entire project structure.

0
Comment actions Permalink

After trying to get another completely new and empty .NET Core 3.1 project working with MSTest, I think I've come to the conclusion that MSTest does not actually support .NET Core 3.1. The Rider log seemed to show that it was reverting to .NET Framework 4 in some cases (even though I was targetting only .NET Core 3.1), and then got an exception when trying to retreive System.Runtime 4.2.2.0. From what I can see, Microsoft.NET.Test.Sdk supports .NET Core 2.1, not 3.1, and indeed, changing my very simple test setup to .NET Core 2.1 instead, things work right away.

It would be nice if I had some confirmation of that though. It doesn't seem very well documented.

It should be easy to test: 1 new .NET Core 3.1 Class Library and 1 new  .NET Core 3.1 MSTest project with package references like I originally posted. Reference the library from the test project, and write some code and a test method and try to run the test. Should end up with inconclusive, the test was not run, and a rider log that shows the System.Runtime load exception.

On the other hand, my original issue was with dotCover, and I seemed to be able to run the tests just not cover them, so maybe it _should_ work, but then I don't know what the problem is now.

My question now is: does MSTest support .NETCore 3.1? I can't tell one way or the other.

0
Comment actions Permalink

Dave Cousineau, I'm mostly interested in Unit Test session and backend logs, but it would be better to have the whole bundle. On tracker you can set up visibility of request to only JB representative, we can also sign up NDA if required. I have also tested MSTest project with netcoreapp 3.1 as target framework on the latest Rider and have not faced any issues with running or coverage, so I need more information from your set up to be able to take a closer look.

0
Comment actions Permalink

K I've determined that under unit test settings, if "Default .NET Framework version:" is set to anything other than "Automatic", that tests for .NET Core will just not run, since it defaults to whatever version of .NET Framework you have selected, even though it's a .NET Core test project.

For example, if I select .NET Framework 4.7, I see lines like this in the rider unit test output log:

Provider: MSTest
Target Framework: .NETCoreApp,Version=v3.1
Strategy: MsTestTestRunnerRunStrategy
Runtime Environment: TestRunnerRuntimeEnvironment
Project: _____
TargetPlatform: X86
TargetFrameworkId: .NETFramework,Version=v4.7
IsUnmanaged: False

...

TestRunner: Discoverer [MSTest][Discovery][C:\___\bin\x86\Debug\netcoreapp3.1\___.dll] Unable to load types from the test source 'C:\___\bin\x86\Debug\netcoreapp3.1\___.dll'. Some or all of the tests in this source may not be discovered.
Error: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

This is not really related to my original dotCover issue but is a separate unit test issue I've encountered on a different workstation and codebase.

0
Comment actions Permalink

Could you please specify Rider version you are using? I tried to perform the same using the following sample on the latest available Rider 20.3 and have not faced such issues. 

0

Please sign in to leave a comment.