Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Visual Studio

Visual Studio: Fix a Test Project That Builds Fine Alone but Fails to Discover Any Tests After a NuGet Restore

- 04.10.26 - ErcanOPAK

🛠️ The Test Project That Built, and Then Found Nothing

A test project depends on a specific test adapter package to let Visual Studio’s Test Explorer discover and run the tests it contains, and that adapter is resolved and loaded independently of whether the project itself compiles successfully – which means a restore that pulls in a slightly different, incompatible version of the test adapter, the test framework, or the shared SDK they both depend on can leave a project that builds completely cleanly with zero tests showing up anywhere in Test Explorer, no error reported, and no obvious link back to the restore that just ran moments earlier.

🔎 The Problem

1. Test project builds successfully - Build Succeeded, zero errors,
   zero warnings related to the test framework itself.
2. Test Explorer shows the test project listed, but with zero
   individual tests underneath it - no error icon, no red text,
   just an empty node where dozens of tests used to appear.
3. Recent action: ran a NuGet restore after pulling teammates'
   changes, which updated the test SDK package
   (Microsoft.NET.Test.Sdk) to a newer version, while the test
   adapter package (e.g. xunit.runner.visualstudio) stayed pinned
   at its previous version in this project's own file.
4. Output window, Tests category, shows a quiet warning about an
   adapter failing to load or a version mismatch - easy to miss
   entirely unless that specific output category is selected.

The build succeeds because the test SDK/adapter mismatch doesn't
actually break compilation - it only affects whether Test Explorer's
discovery process can successfully load and talk to the adapter at
runtime, which is a completely separate step from compiling the
project's code.

✅ Fix: Keep the Test SDK and Adapter Versions Moving Together

  • Check the Output window’s Tests category specifically after any restore that touches a test project, since the actual warning about a failed or mismatched adapter load is usually sitting there in plain text, just in a pane most people never select unless they already suspect test discovery is broken.
  • Update the test framework’s adapter package to a version compatible with the test SDK version the restore just pulled in, rather than leaving one pinned while the other moves – the two are meant to be upgraded together, not independently.
  • Add a central package version management file, or explicitly pin both the test SDK and the adapter package together in the same place, so a future restore can’t silently update one without the other drifting out of a compatible version range.

⚠️ Why This Is Easy to Miss

  • A successful build gives every visual signal that the project is in a healthy state, so there’s no natural reason to suspect the restore that just ran is actually the cause of a completely separate-seeming problem in Test Explorer a few minutes later.
  • Test Explorer showing an empty, test-free project looks identical whether the cause is an adapter version mismatch, a build configuration issue, or genuinely zero tests existing in that project – there’s no prominent error state to distinguish “broken discovery” from “nothing to discover.”

Compiling a test project and actually discovering its tests are two separate jobs – a restore can quietly break the second one while leaving the first looking perfectly fine.

— Developer Tip

Related posts:

Visual Studio: Fix the Live Unit Testing Icon Staying Gray on a Test Project Forever Because the Pro...

Visual Studio: Fix the Live Unit Testing Icon Staying Gray on a Test Project Forever Because the Pro...

Visual Studio: Memory Profiling to Kill Hidden Memory Leaks

Visual Studio: Memory Profiling to Kill Hidden Memory Leaks

Visual Studio Slows Down After You Add Just One Project

Visual Studio Slows Down After You Add Just One Project

Views: 18
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

ASP.NET Core: Fix a File Upload That Times Out on Slow Connections Only Because Kestrel’s Minimum Data Rate Feature Kicked In
WordPress: Fix Search Results That Return Pages From a Theme You Deactivated Months Ago

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 561 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com