vscode-csharp: VSCode "Error processing launch options at field: program" popup when debugging an xunit test

Steps to Reproduce:

  1. Setup a project with xunit:
    using System;
    using System.Reflection;
    using Xunit;
    
    public class Fact2Attribute : FactAttribute
    {
        public Fact2Attribute()
        {
            Type thisType = GetType();
             MethodInfo theMethod = thisType.GetMethod("MyOtherMethod");
             var result = theMethod.Invoke(this, null);
        }

            public void MyOtherMethod(string singleParam){}
    }
        [Fact2]
        public void ATestMethod()
        {           
            Assert.True(false);
        }
  1. Compile and using Code lens press Debug Test

Expected behavior

It should fail before the test runs as we are invoking MyOtherMethod without a param. An appropriate message should be shown.

Actual behavior

I get this window popup: image

I don’t get any error messages in console. If I try and run test rather than debug test it seems to completely bypass the test so I end up with:

Total tests: 0. Passed: 0. Failed: 0. Skipped: 0

If I run dotnet test I get the same result as run test in code lens.

Versions:

dotnet 2.1.105 VS code 1.22.2 Omisharp 1.14.0 Ubuntu 16.04.4 LTS

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 8
  • Comments: 17 (3 by maintainers)

Most upvoted comments

Version 1.23.0 fixed it for me. Thanks!

Not sure why this is in closed state, as the issue persists in C# Extension: 1.22.1 (latest) Closed status made me open similar issue - #3965

@JoeRobich - Any ETA on the release of this fix ? This just made me download VS 2019, just to run the unit tests !

Update

I confirm it worked for me with C# Extension**: 1.23.0 , instructions to download beta helped !

Seems like this should still be open - it’s still an issue in 1.22.1 anyway.

Repro from #3901:

Clone https://github.com/vchirikov/omnisharp_vscode_repro Open in VS Code Open UnitTest1.cs Click on Debug test codelens link on UnitTest1.Test1

OmniSharp trace logging for the Debug Test request:

[info]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"TestSession.Connected","Payload":null}
[dbug]: OmniSharp.DotNetTest.VSTestManager
        send: {"MessageType":"ProtocolVersion","Payload":1}
[info]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"ProtocolVersion","Payload":1}
[info]: OmniSharp.DotNetTest.DebugSessionManager
        Debug session started.
[dbug]: OmniSharp.DotNetTest.VSTestManager
        send: {"MessageType":"TestDiscovery.Start","Payload":{"Sources":["/Users/joeyrobichaud/Source/omnisharp_vscode_repro/artifacts/omnisharp-vscode-repro.dll"],"RunSettings":"\n<RunSettings>\n    <RunConfiguration>\n        <TargetFrameworkVersion>.NETCoreApp,Version=v3.1</TargetFrameworkVersion>\n    </RunConfiguration>\n</RunSettings>"}}
[dbug]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"TestSession.Message","Payload":{"MessageLevel":0,"Message":"[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.1 (64-bit .NET Core 3.1.4)"}}
[dbug]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"TestSession.Message","Payload":{"MessageLevel":0,"Message":"[xUnit.net 00:00:00.41]   Discovering: omnisharp-vscode-repro"}}
[dbug]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"TestSession.Message","Payload":{"MessageLevel":0,"Message":"[xUnit.net 00:00:00.46]   Discovered:  omnisharp-vscode-repro"}}
[dbug]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"TestDiscovery.TestFound","Payload":[{"Properties":[{"Key":{"Id":"TestCase.FullyQualifiedName","Label":"FullyQualifiedName","Category":"","Description":"","Attributes":1,"ValueType":"System.String"},"Value":"omnisharp_vscode_repro.UnitTest1.Test1"},{"Key":{"Id":"TestCase.ExecutorUri","Label":"Executor Uri","Category":"","Description":"","Attributes":1,"ValueType":"System.Uri"},"Value":"executor://xunit/VsTestRunner2/netcoreapp"},{"Key":{"Id":"TestCase.Source","Label":"Source","Category":"","Description":"","Attributes":0,"ValueType":"System.String"},"Value":"/Users/joeyrobichaud/Source/omnisharp_vscode_repro/artifacts/omnisharp-vscode-repro.dll"},{"Key":{"Id":"TestCase.CodeFilePath","Label":"File Path","Category":"","Description":"","Attributes":0,"ValueType":"System.String"},"Value":"/Users/joeyrobichaud/Source/omnisharp_vscode_repro/UnitTest1.cs"},{"Key":{"Id":"TestCase.DisplayName","Label":"Name","Category":"","Description":"","Attributes":0,"ValueType":"System.String"},"Value":"omnisharp_vscode_repro.UnitTest1.Test1"},{"Key":{"Id":"TestCase.Id","Label":"Id","Category":"","Description":"","Attributes":1,"ValueType":"System.Guid"},"Value":"59b97bed-adc2-eb3a-02dc-4b5f9bb224c5"},{"Key":{"Id":"TestCase.LineNumber","Label":"Line Number","Category":"","Description":"","Attributes":1,"ValueType":"System.Int32"},"Value":10},{"Key":{"Id":"XunitTestCase","Label":"xUnit.net Test Case","Category":"","Description":"","Attributes":0,"ValueType":"System.String"},"Value":":F:omnisharp_vscode_repro.UnitTest1:Test1:1:0:ed34c1d9dc01408382beebef7592a408"}]}]}
[dbug]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"TestDiscovery.Completed","Payload":{"TotalTests":1,"LastDiscoveredTests":null,"IsAborted":false,"Metrics":{}}}
[dbug]: OmniSharp.DotNetTest.VSTestManager
        send: {"MessageType":"TestExecution.GetTestRunnerProcessStartInfoForRunSelected","Payload":{"TestCases":[{"Properties":[{"Key":{"Id":"TestCase.FullyQualifiedName","Label":"FullyQualifiedName","Category":"","Description":"","Attributes":1,"ValueType":"System.String"},"Value":"omnisharp_vscode_repro.UnitTest1.Test1"},{"Key":{"Id":"TestCase.ExecutorUri","Label":"Executor Uri","Category":"","Description":"","Attributes":1,"ValueType":"System.Uri"},"Value":"executor://xunit/VsTestRunner2/netcoreapp"},{"Key":{"Id":"TestCase.Source","Label":"Source","Category":"","Description":"","Attributes":0,"ValueType":"System.String"},"Value":"/Users/joeyrobichaud/Source/omnisharp_vscode_repro/artifacts/omnisharp-vscode-repro.dll"},{"Key":{"Id":"TestCase.CodeFilePath","Label":"File Path","Category":"","Description":"","Attributes":0,"ValueType":"System.String"},"Value":"/Users/joeyrobichaud/Source/omnisharp_vscode_repro/UnitTest1.cs"},{"Key":{"Id":"TestCase.DisplayName","Label":"Name","Category":"","Description":"","Attributes":0,"ValueType":"System.String"},"Value":"omnisharp_vscode_repro.UnitTest1.Test1"},{"Key":{"Id":"TestCase.Id","Label":"Id","Category":"","Description":"","Attributes":1,"ValueType":"System.Guid"},"Value":"59b97bed-adc2-eb3a-02dc-4b5f9bb224c5"},{"Key":{"Id":"TestCase.LineNumber","Label":"Line Number","Category":"","Description":"","Attributes":1,"ValueType":"System.Int32"},"Value":10},{"Key":{"Id":"XunitTestCase","Label":"xUnit.net Test Case","Category":"","Description":"","Attributes":0,"ValueType":"System.String"},"Value":":F:omnisharp_vscode_repro.UnitTest1:Test1:1:0:ed34c1d9dc01408382beebef7592a408"}]}],"DebuggingEnabled":true,"RunSettings":"\n<RunSettings>\n    <RunConfiguration>\n        <TargetFrameworkVersion>.NETCoreApp,Version=v3.1</TargetFrameworkVersion>\n    </RunConfiguration>\n</RunSettings>"}}
[dbug]: OmniSharp.DotNetTest.VSTestManager
        read: {"MessageType":"TestSession.Message","Payload":{"MessageLevel":0,"Message":"[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.1 (64-bit .NET Core 3.1.4)"}}
[dbug]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 68,
  "Command": "/v2/debugtest/getstartinfo",
  "Running": true,
  "Success": true,
  "Message": null,
  "Body": {
!    "FileName": null,
    "Arguments": null,
    "WorkingDirectory": null,
    "EnvironmentVariables": null,
    "Succeeded": true,
    "ContextHadNoTests": false,
    "FailureReason": null
  },
  "Seq": 471,
  "Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 70,
  "Command": "/v2/debugtest/stop",
  "Arguments": {
    "FileName": "/Users/joeyrobichaud/Source/omnisharp_vscode_repro/UnitTest1.cs"
  }
}
[dbug]: OmniSharp.DotNetTest.VSTestManager
        send: {"MessageType":"TestSession.Terminate","Payload":{}}
[info]: OmniSharp.DotNetTest.DebugSessionManager
        Debug session ended.
[dbug]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 70,
  "Command": "/v2/debugtest/stop",
  "Running": true,
  "Success": true,
  "Message": null,
  "Body": {},
  "Seq": 504,
  "Type": "response"
}

Also experiencing this on windows using NUnit tests:

dotnet 2.2.103 VS code 1.35.0 Omnisharp: 1.19.1 Windows: 10.0.17134 Build 17134 NUnit3TestAdapter: 3.8.0 Microsoft.NET.Test.Sdk: 15.0.0 NUnit: 3.6.1