dotnet / dotnet/vscode-csharp

Cannot debug Nunit Parametrized TestFixture

Open
#5,695 2 comments 1 reaction 0 assignees View on GitHub
Test
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
18h 40m
Merged PRs (30d)
31

Description

## Problem description
I downloaded example Parametrized TestFixture file from: [Nunit Parametrized TestFixture](https://docs.nunit.org/articles/nunit/writing-tests/attributes/testfixture.html#parameterized-test-fixtures) and when i want to debug in VSCode it fails with exception System.ArgumentException: Selected argument cannot be null or empty. (Parameter 'tests'). When I run "dotnet test" from terminal test start without any issue.

## Environment data
`dotnet --info` output:
Host:
Version: 6.0.16
Architecture: x64
Commit: 1e620a42e7

.NET SDKs installed:
3.1.426 [C:\Program Files\dotnet\sdk]
6.0.408 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
VS Code version:
Version: 1.78.2 (user setup)
Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435
Date: 2023-05-10T14:39:26.248Z
Electron: 22.5.2
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621
Sandboxed: Yes
C# Extension version:

## OmniSharp log
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 10.0.22621.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.408 17.3.2 - "C:\Program Files\dotnet\sdk\6.0.408\"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.408 17.3.2 - "C:\Program Files\dotnet\sdk\6.0.408\"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'c:\Users\kolarik\Downloads\nunitTest\parametrizedNunit'.
[info]: OmniSharp.Cake.CakeProjectSystem
Did not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
No solution files found in 'c:\Users\kolarik\Downloads\nunitTest\parametrizedNunit'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Users\kolarik\Downloads\nunitTest\parametrizedNunit\parametrizedNunit.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'c:\Users\kolarik\Downloads\nunitTest\parametrizedNunit'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'c:\Users\kolarik\Downloads\nunitTest\parametrizedNunit' on host 9700.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: c:\Users\kolarik\Downloads\nunitTest\parametrizedNunit\parametrizedNunit.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'c:\Users\kolarik\Downloads\nunitTest\parametrizedNunit\parametrizedNunit.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project 'c:\Users\kolarik\Downloads\nunitTest\parametrizedNunit\parametrizedNunit.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: parametrizedNunit
Received response for /v2/getcodeactions but could not find request.
Received response for /v2/gotodefinition but could not find request.
[info]: OmniSharp.DotNetTest.VSTestManager
read: {"MessageType":"TestSession.Connected","Payload":null}
[info]: OmniSharp.DotNetTest.VSTestManager
read: {"MessageType":"ProtocolVersion","Payload":1}
[info]: OmniSharp.DotNetTest.DebugSessionManager
Debug session started.
[warn]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 81,
"Command": "/v2/debugtest/getstartinfo",
"Arguments": {
"FileName": "c:\\Users\\kolarik\\Downloads\\nunitTest\\parametrizedNunit\\UnitTest1.cs",
"MethodName": "parametrizedNunit.ParameterizedTestFixture.TestInequality",
"TestFrameworkName": "nunit",
"TargetFrameworkVersion": ".NETCoreApp,Version=v6.0",
"NoBuild": false
}
}
[fail]: OmniSharp.Stdio.Host
************ Response (4187.5981ms) ************
{
"Request_seq": 81,
"Command": "/v2/debugtest/getstartinfo",
"Running": true,
"Success": false,
"Message": "\"System.NullReferenceException: Object reference not set to an instance of an object.\\r\\n at OmniSharp.DotNetTest.VSTestManager.DebugGetStartInfoAsync(String[] methodNames, String runSettings, String testFrameworkName, String targetFrameworkVersion, CancellationToken cancellationToken) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.DotNetTest\\\\VSTestManager.cs:line 170\\r\\n at OmniSharp.Endpoint.EndpointHandler`2.GetFirstNotEmptyResponseFromHandlers(ExportHandler`2[] handlers, TRequest request) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 217\\r\\n at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 233\\r\\n at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 142\\r\\n at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 258\"",
"Body": null,
"Seq": 284,
"Type": "response"
## .NET Test log
NUnit Adapter 4.2.0.0: Test discovery starting
NUnit Adapter 4.2.0.0: Test discovery complete
System.ArgumentException: Selected argument cannot be null or empty.. (Parameter 'tests')
at Microsoft.VisualStudio.TestPlatform.ObjectModel.ValidateArg.NotNullOrEmpty[T](IEnumerable`1 arg, String parameterName)
at Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunCriteria..ctor(IEnumerable`1 tests, Int64 frequencyOfRunStatsChangeEvent, Boolean keepAlive, String testSettings, TimeSpan runStatsChangeEventTimeout, ITestHostLauncher testHostLauncher, TestSessionInfo testSessionInfo, Boolean debugEnabledForTestSession)
at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.RunTests(TestRunRequestPayload testRunRequestPayload, ITestHostLauncher3 testHostLauncher, ITestRunEventsRegistrar testRunEventsRegistrar, ProtocolConfig protocolConfig)
at Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.<>c__DisplayClass23_0.b__0()
## Steps to reproduce

1. Download this exmaple project [parametrizedNunit.zip](https://github.com/OmniSharp/omnisharp-vscode/files/11590570/parametrizedNunit.zip)
2. Open in VSCode
3. Run dotnet restore / dotnet build
4. Try to debug some test

## Expected behavior
Debug mode is stared

## Actual behavior
System.ArgumentException: Selected argument cannot be null or empty.. (Parameter 'tests') is shown.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.