How to run all tests in Visual Studio Code

Miguel Gamboa picture Miguel Gamboa · Jan 31, 2017 · Viewed 49.7k times · Source

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 Visual Studio Code.

However, I am looking how can I run all tests contained in a test suite class in VS Code (without debug)?

The only way I found was adding to launch.json a specific configuration as the following one, but which I can only run in debug (I would like to run it without debug):

{
  "name": ".NET Core Xunit tests",
  "type": "coreclr",
  "request": "launch",
  "preLaunchTask": "build",
  "program": "/usr/local/share/dotnet/dotnet",
  "args": ["test"],
  "cwd": "${workspaceRoot}/test/MyProject.Tests",
  "externalConsole": false,
  "stopAtEntry": false,
  "internalConsoleOptions": "openOnSessionStart"
}

Answer

Jun Han picture Jun Han · Aug 12, 2017

There is a much easier way to run all tests:

  1. Install the .NET Core Test Explorer extension
  2. Open a .NET Core test project in VS Code, or set dotnet-test-explorer.testProjectPath to the folder path of .NET Core test project in settings.json
  3. In .NET Test Explorer of Explorer view, all the tests will be automatically detected, and you are able to run all tests or a certain test

.NET Test Explorer