Visual Studio 2019 Test Explorer puts all tests under "Not Run Tests"
Asked Answered
S

3

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

Shadow answered 16/12, 2019 at 4:48 Comment(0)
B
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.

Banner answered 24/1, 2020 at 11:9 Comment(3)
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).Banner
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.Steamroller
I use NUnit and had the same issue. I also install Nunit3TestAdapter to get it run, in addition to the changes described above.Yakut
T
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.

Tartaglia answered 6/4, 2020 at 13:45 Comment(0)
R
2

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

Remind answered 17/4, 2021 at 16:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.