Open user19958 opened 1 year ago
I've been having this problem on and off for some time now, only with the TestCaseSource
NUnit test attribute.
Sometimes it works, sometimes it doesn't, no idea why.
I have the same issues with the new 2.x version.
And in my case problem with the SetName
call for the TestCaseData
private static IEnumerable TestCases()
{
yield return new TestCaseData(1, 2, 3).SetName("Some test case");
}
[TestCaseSource(nameof(TestCases))]
public async Task TestCase(int param1, int param2, int param3)
{
...
}
So if I remove the .SetName("Some test case");
VSCode can run the TestCase
function.
Problem description
I downloaded example Parametrized TestFixture file from: Nunit Parametrized TestFixture 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
Received response for /v2/getcodeactions but could not find request. Received response for /v2/gotodefinition but could not find 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 } }
{ "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.EndpointHandler2.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](IEnumerableb__0()
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.Steps to reproduce
Expected behavior
Debug mode is stared
Actual behavior
System.ArgumentException: Selected argument cannot be null or empty.. (Parameter 'tests') is shown.