Diagnosing Missing NUnit Tests in Visual Studio Test Explorer

Andy LiAndy Li
3 min read

If your NUnit tests are missing from Visual Studio Test Explorer, follow these steps to diagnose the issue—from running a basic test command to capturing detailed discovery diagnostics.


1. Run Tests Using the Basic Command

Navigate to your test project's output directory (where the DLL is built) and run:

dotnet test -t YourTestAssembly.dll

Note:
The -t option is not a valid parameter for dotnet test to specify the assembly directly.
Instead, run dotnet test in your test project directory or specify the project file.

Correct usage:

# Run from the test project directory
dotnet test

# Or specify the project file
dotnet test YourTestProject.csproj

2. Increase Verbosity for More Information

To get more information about test discovery and execution, add the --verbosity option:

dotnet test --verbosity normal

For even more detail:

dotnet test --verbosity detailed

3. Run with Diagnostic Verbosity

Set verbosity to diagnostic for the most detailed output:

dotnet test --verbosity diagnostic

4. Capture Diagnostic Logs to a File

To generate a comprehensive log file for deeper troubleshooting, use the --diag option:

dotnet test --verbosity diagnostic --diag discovery.log
  • This writes all diagnostic information to discovery.log, which you can review for missing tests, discovery failures, or adapter errors.

5. Run Tests Directly from a Compiled DLL with VSTest (Advanced)

If you want to run tests from the compiled DLL (and not the project), use dotnet vstest:

dotnet vstest YourTestAssembly.dll --Diag:discovery.log --logger:console;verbosity=detailed

6. Run Individual Tests with Filters

You can run specific NUnit tests using the --filter option:

  • By Fully Qualified Name:

      dotnet test --filter "FullyQualifiedName=YourNamespace.YourTestClass.YourTestMethod"
    
  • By Category:

      dotnet test --filter "TestCategory=Smoke"
    

    For NUnit, use [Category("Smoke")] on your test methods or classes.

  • By Test Class:

      dotnet test --filter "FullyQualifiedName~YourNamespace.YourTestClass"
    

7. Checklist for NUnit Test Discovery

  • Test Attributes: Use [Test] or [TestCase(...)] for test methods.

  • NuGet Packages: Ensure your project references:

  • Public Methods: Test methods must be public.

  • Build Issues: Tests won’t be discovered if your project fails to build.

  • Target Framework: Use a supported target (e.g., net6.0 or net8.0).


8. Troubleshooting with the Diagnostic Log

Open discovery.log and look for:

  • Messages like "No test is available in", "Failed to find", or "Could not load file or assembly".

  • Errors or warnings related to test adapters, assembly loading, or test attribute usage.


9. Still Stuck?

  • Clean and rebuild your solution.

  • Restart Visual Studio.

  • Update all relevant NuGet packages.

  • Share key parts of your diagnostic log with your team for more help.


By following these steps—from running basic test commands up to detailed diagnostic logging—you can systematically diagnose and resolve missing NUnit test issues in Visual Studio Test Explorer.

0
Subscribe to my newsletter

Read articles from Andy Li directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Andy Li
Andy Li