如何在 Visual Studio Code 中运行所有测试 [英] How to run all tests in Visual Studio Code

查看:49
本文介绍了如何在 Visual Studio Code 中运行所有测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最新版本的 VS Code 已经提供了一种运行单个测试的简单方法,正如

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"
}

解决方案

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

这篇关于如何在 Visual Studio Code 中运行所有测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆