Visual Studio Test Explorer not running tests

problem

I have a .NET 6 project with xUnit unit tests opened in Visual Studio 2022.

I see the unit tests in the Test Explorer window and when I click to Run it builds the project but doesn't run any of them.

solution

There might be multiple causes for this, what worked for me was either:

  • specifically clicking Build on the unit test project (building the whole solution wasn't helping), or
  • running in a command prompt dotnet test MyProject.Tests.Unit.csproj, after navigating to the unit test project's folder, with my specific csproj name there.

After that I still had issues with new unit tests added, Test Explorer was either skipping them, or running old versions of them. Doing one of the two options above got the unit tests running correctly. Although it's still weird, Test Explorer should just work.

Gravatar
Author: Dan Dumitru
Last Edit: July 9, 2024
1 Thanks received
Last Edit July 9, 2024
Created July 9, 2024
Views 27
Tags
Visual Studio
xUnit

Join us!

Do you like this website?

Bookmark it and come back here to write a post yourself when you run into something shareable.

Early collaborators will get to own a part of the project (5 to 20%)... >> read more

Your Comment

Feel free to post additional info or improvement suggestions.
preview
Optional, never shown, displays gravatar.

Formatting Tips

This editor uses Markdown to easily add code in your posts.

Triple backticks for full line(s) of code (or indent 4 spaces)

```
let foo = 'bar';
```

[link text](http://a.com)

*italic* **bold**

More Tips