11
votes

I have a ASP.Net Core 3 project with Visual Studio Professional 19.4.1 with xUnit 2.4.0. I have a couple of tests written there. My problem is that Visual Studio shows all the tests in this project always under "Not Run Tests". The same tests run well with command line (dotnet test) or another computer. Repairing/Reinstalling Visual Studio did not help. Any help is much needed!

UPDATE: I also realized that extension DotNet Extensions for Test Explorer is not present on this computer. This is present on other computer where these work. The problem, however, is how and where to get this extension from?

I already have xunit.runner.visualstudio 2.4.0 included in the project.

enter image description here

Any help is much valuable!!!

3

3 Answers

8
votes

Upgrade the nuget package Microsoft.NET.Test.Sdk to version 16.4.0 (or newer).

When creating a new xunit project in vs2019, the version of Microsoft.NET.Test.Sdk installed is 16.2.0, which xunit.runner.visualstudio (v2.4.0 or newer) doesn't seem to work in.

1
votes

Okay, got the same error where it simply did not run any of my tests despite obviously knowing about them (visible in test explorer in Test > Test Explorer). When I pressed Run or Run all tests, it just categorized them all as "not run". To fix this I lowered my .Net Core Target framework from 3.1 to 3.0 and that fixed it for me after a clean, rebuild of the unit test project.

This error may occur if you have cloned from a repository that used a different framework.

1
votes

Installing both xunit.runner.visualstudio and xunit.runner.console worked for me.