How to run all tests in Visual Studio Code

前端 未结 5 2281
没有蜡笔的小新
没有蜡笔的小新 2020-12-24 06:01

The latest version of VS Code already provides an easy way of running a single test as pointed on Tyler Long\'s answer to the question Debugging xunit tests in .NET Core and

5条回答
  •  醉酒成梦
    2020-12-24 06:31

    To run tests in Visual Studio (VS) Code, you need to add a tasks.json file to the .vscode directory (if you don't already have it). Then configure your test task as follows:

    {
        "version": "2.0.0",
        "tasks": [
            {
                ... // Other tasks
            },
            {
                "label": "test",
                "command": "dotnet",
                "type": "shell",
                "args": [
                    "test",
                    "${workspaceFolder}/TestProjectName/TestProjectName.csproj"
                ],
                "group": "test",
                "problemMatcher": "$msCompile",
                "presentation": {
                    "echo": true,
                    "reveal": "always",
                    "focus": false,
                    "panel": "shared",
                    "showReuseMessage": true,
                    "clear": false
                }
            }
        ]
    }
    

    When you have that saved, run the following command Cmd-Shift-P on Mac or Ctrl-Shift-P on Linux and Windows within the VS Code interface then type Run Test Task, press Enter and select test.

    The above configuration should work for the latest Insider and Stable releases of VS Code as at April 2020 (version 1.41).

提交回复
热议问题