Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 993
Abhi Avatar asked Dec 16 '19 04:12

Abhi


People also ask

How do I run all test cases in Visual Studio?

To run all the tests in a default group, choose the Run icon and then choose the group on the menu. Select the individual tests that you want to run, open the right-click menu for a selected test and then choose Run Selected Tests (or press Ctrl + R, T).

How do I stop a test case from running in Visual Studio?

You need to close the Test Explorer Window to prevent automatic running.

Why does Visual Studio skip test cases?

The Test Settings file you're pointing to could be invalid. Make sure the settings file has the right parameters (either remote or local, etc.), and then go to Tests>Test Settings>Select Test Settings File in the toolbar to select the valid file.


Video Answer


2 Answers

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.

like image 104
Jammyjamjamman Avatar answered Sep 24 '22 13:09

Jammyjamjamman


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.

like image 27
Chaos Avatar answered Sep 21 '22 13:09

Chaos