Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Test Explorer is empty and 'No tests found in the selected file or folder' for Run/Debug Tests context menu #1620

Closed
kosa-gyula-77 opened this issue Nov 19, 2024 · 6 comments
Labels
area-test Test discovery, execution, debugging bug Something isn't working

Comments

@kosa-gyula-77
Copy link

Describe the Issue

Symptoms

  1. Test Explorer is empty. It renders 'No tests have been found in the worskpace yet.'
  2. 'No tests found in the selected file or folder' is rendered when selecting Run Tests/Debug Tests context menu on a test class file or test project.

Steps To Reproduce

C# test project references

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
    <PackageReference Include="NUnit" Version="3.13.3" />
    <PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
    <PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
    <PackageReference Include="coverlet.collector" Version="3.2.0" />
  </ItemGroup>

Expected Behavior

Expected

  1. Test Explorer renders tests
  2. Run Tests/Debug Tests context menu on a test class file or test project runs tests

Environment Information

Visual Studio Code

Version: 1.95.3 (user setup)
Commit: f1a4fb101478ce6ec82fe9627c43efbf9e98c813
Date: 2024-11-13T14:50:04.152Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.22631

C# Dev Kit

v1.13.9

@webreidi
Copy link

@kosa-gyula-77 Have you performed a full build of your project after opening it in VS Code? Tests will not be discovered until a build has been performed.

@kosa-gyula-77
Copy link
Author

Have you performed a full build of your project after opening it in VS Code? Tests will not be discovered until a build has been performed.

@webreidi Yes, I issued a dotnet build from the Terminal in VS Code.

@webreidi
Copy link

@kosa-gyula-77 can you try running the build within VS Code (Ctrl+Shift+B or Open Command Palette and select .NET: Build or right click on the project in Solution Explorer and select Build) and see if the tests are discovered when using that build?

@kosa-gyula-77
Copy link
Author

@webreidi Your proposed solution works for a very similar C# solution, but it does not work for the originally used C# solution.

What is strange that VSCode says

The active document is not part of the open workspace

when I open a TestFixture C# source code file in the problematic solutions.

@webreidi
Copy link

@kosa-gyula-77 Hmm. Okay, that means that for some reason part or all of that test project is not loading properly in C# Dev Kit. At the bottom of VSCode, you should see a section that says "Projects: " and if you don't have a file open it will say the number of projects that are open, and if you do have a file open it will say which project the open file is found in. When you open this solution, does it register the correct number of projects? Is there an error there?

@kosa-gyula-77
Copy link
Author

@webreidi Thanks for the hints! The issue was that the unit test's csproj has not been added to the sln file. Once I added it Projects: increased by one and the tests started to show up in the Testing pane.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-test Test discovery, execution, debugging bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants