【问题标题】:vscode-dotnet-test-explorer debugging test "Waiting for Process to Attach"vscode-dotnet-test-explorer 调试测试“等待进程附加”
【发布时间】:2020-06-20 22:28:09
【问题描述】:

抱歉在这里发帖,但我在互联网上四处寻找,找不到任何东西。

我正在尝试使用扩展名".NET Core Test Explorer" 在 VSCode 中调试我的单元测试。

我可以运行测试就好了,但我不能调试它们 - 这是输出:

Test run for Gameboy.Tests.MMUTests.Memory_ValidateBytes_WithSuccess, expecting 1 test results file(s) in total
Executing dotnet build in /Users/kevin/Repos/NetCore GameBoy/Gameboy.Tests/
Executing dotnet test --no-build --logger "trx;LogFileName=/var/folders/6d/p11jk7052lx2m4_fj5vk6qwc0000gn/T/test-explorer-sw7Rdk/0.trx" --filter "FullyQualifiedName=Gameboy.Tests.MMUTests.Memory_ValidateBytes_WithSuccess" in /Users/kevin/Repos/NetCore GameBoy/Gameboy.Tests/
Process 4345 started
Waiting for debugger to attach
Waiting for debugger to attach
Waiting for debugger to attach
Waiting for debugger to attach
Waiting for debugger to attach
Waiting for debugger to attach
Waiting for debugger to attach

基本上,我猜它永远不允许调试器附加。即使我手动附加到上述 PID,使用此任务:

{
    "name": ".NET Core Attach",
    "type": "coreclr",
    "request": "attach",
    "processId": "${command:pickProcess}"
}

它仍然没有在我的测试中达到我的断点。

任何帮助将不胜感激。

这是 tasks.json 和 launch.json 的完整输出

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/Gameboy.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "publish",
            "command": "dotnet",
            "type": "process",
            "args": [
                "publish",
                "${workspaceFolder}/Gameboy.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        },
        {
            "label": "watch",
            "command": "dotnet",
            "type": "process",
            "args": [
                "watch",
                "run",
                "${workspaceFolder}/Gameboy.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}
{
  // Use IntelliSense to find out which attributes exist for C# debugging
  // Use hover for the description of the existing attributes
  // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
  "version": "0.2.0",
  "configurations": [
    {
      "name": ".NET Core Launch (console)",
      "type": "coreclr",
      "request": "launch",
      "preLaunchTask": "build",
      // If you have changed target frameworks, make sure to update the program path.
      "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Gameboy.dll",
      "args": [],
      "cwd": "${workspaceFolder}",
      // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
      "console": "internalConsole",
      "stopAtEntry": false
    },
    {
      "name": ".NET Core Attach",
      "type": "coreclr",
      "request": "attach",
      "processId": "${command:pickProcess}"
    }
  ]
}

【问题讨论】:

    标签: testing .net-core visual-studio-code


    【解决方案1】:

    我看到了同样的情况,很遗憾没有解决方案。但是,顶部相关帖子中的this answer 确实为我提供了一种解决方法。我从那里复制了下面的图片。

    我基本上只将测试资源管理器用于探索测试,然后双击条目以转到其源代码。这甚至适用于生成的测试,例如使用 SpecFlow 时。在测试方法的位置,只需单击方法标题上方的“调试测试”链接,如下图所示。这会启动调试器,完全跳过测试资源管理器。

    【讨论】:

    • 谢谢。然而,对我来说,仍然行不通。引发“无法解构‘(中间值)’的属性‘debugEventListener’,因为它是未定义的”。现在将对此进行调查...
    猜你喜欢
    • 2020-02-28
    • 2018-09-23
    • 2023-03-19
    • 2018-10-15
    • 2016-08-26
    • 2013-09-24
    • 2020-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多