15

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!!!

Abhi
  • 1,624
  • 2
  • 16
  • 29

3 Answers3

11

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.

Jammyjamjamman
  • 126
  • 1
  • 4
  • 2
    I noticed that sometimes this just upgrading this package doesn't work... after upgrading the sdk, restarting visual studio + rebuild + (re)run guarantees that the tests work for me. Also, this bug occurs with MSTest as well (and the same solution works). – Jammyjamjamman Feb 21 '20 at 10:44
  • This page is installed for new xunit .net core projects. I thought maybe it was only used for MSTest projects, but adding it in made my xunit tests work again. – Jacob Jul 10 '20 at 16:25
  • I use NUnit and had the same issue. I also install Nunit3TestAdapter to get it run, in addition to the changes described above. – DavidY Nov 12 '21 at 03:04
2

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.

Chaos
  • 21
  • 1
2

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

noobmaster007
  • 153
  • 2
  • 11