Omnisharp-vscode: Code Lens Run Test/Debug Test options don't show up in NUnit project

Created on 4 May 2020  路  3Comments  路  Source: OmniSharp/omnisharp-vscode

Issue Description

Code Lens doesn't appear

Steps to Reproduce

  1. Open VSCode
  2. See missing options
    image

Expected Behavior

"Run Test"/"Debug Test" options show up in NUnit test files

Actual Behavior

"Run Test"/"Debug Test" options do not show up.

Logs

OmniSharp log

I don't want to post the log since it contains company-specific repo information, but I note that the project I'm looking to run ProjectName.UnitTests doesn't show up in the Omnisharp log at all. The one that is working correctly ProjectName.ApiTests, however, does.

C# log

Getting latest OmniSharp version information
Downloading package 'Latest OmniSharp Version Information' (1 KB).................... Done!

Environment information

VSCode version: 1.44.2
C# Extension: 1.21.17

Mono Information
OmniSharp using built-in mono

Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 3.1.102
Commit: 573d158fea

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/3.1.102/

Host (useful for support):
Version: 3.1.2
Commit: 916b5cba26

.NET Core SDKs installed:
2.2.301 [/usr/local/share/dotnet/sdk]
3.0.102 [/usr/local/share/dotnet/sdk]
3.1.102 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download


Visual Studio Code Extensions

|Extension|Author|Version|
|---|---|---|
|csharp|ms-dotnettools|1.21.17|
|mssql|ms-mssql|1.9.0|
|vscode-docker|ms-azuretools|1.1.0|
|vscode-nuget-package-manager|jmrog|1.1.6|;

Needs More Info Question Triaged

Most helpful comment

@nguillermin I see now. There is a mismatch between the way VS Code workspaces work and the way C# manages a collection of projects. The C# extension only works from a single VS Code workspace so adding additional won't give you the behavior you expect. We have plans to design a better experience around this.

For C# you would typically have a solution file which you can manage with the dotnet cli. Once you've created your solution file and added the project files you want to be a part of your solution, open the folder containing the .sln file in VS Code and it will be available in the project selector.

All 3 comments

I note that the project I'm looking to run ProjectName.UnitTests doesn't show up in the Omnisharp log at all.

@nguillermin If your .sln file includes your UnitTests project, but you aren't seeing it loaded in OmniSharp then a redacted OmniSharp log would be necessary to troubleshoot your issue.

I note that the project I'm looking to run ProjectName.UnitTests doesn't show up in the Omnisharp log at all.

@nguillermin If your .sln file includes your UnitTests project, but you aren't seeing it loaded in OmniSharp then a redacted OmniSharp log would be necessary to troubleshoot your issue.

I guess I don't understand how VSCode works because I've never dealt with an .sln file while using VSCode. I only just "Add folder to workspace".

Incidentally, I just closed my workspace and reloaded the project folder and now its displaying the 'Run Test'/'Debug Test' options. Is there a way to have multiple projects active or should I just have a separate workspace for each?

@nguillermin I see now. There is a mismatch between the way VS Code workspaces work and the way C# manages a collection of projects. The C# extension only works from a single VS Code workspace so adding additional won't give you the behavior you expect. We have plans to design a better experience around this.

For C# you would typically have a solution file which you can manage with the dotnet cli. Once you've created your solution file and added the project files you want to be a part of your solution, open the folder containing the .sln file in VS Code and it will be available in the project selector.

Was this page helpful?
0 / 5 - 0 ratings