如何在 Visual Studio 的特定文件夹中运行单个测试或所有测试? [英] How to run a single test or all tests in a specific folder in Visual Studio?

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

问题描述

因此,我正在从带有 ReSharper 的 Visual Studio 2015 迁移到 Visual Studio 2017,并尝试从我的工作流程中删除 ReSharper.

So I'm moving from Visual Studio 2015 with ReSharper to Visual Studio 2017 and I'm trying to remove ReSharper from my workflow.

我知道什么 CTRL+R,T 运行整个 TestClass 或所有测试,具体取决于您运行它的位置.似乎在单个单元测试中选择某些内容仍会运行整个测试类.

I know what CTRL+R,T runs either a whole TestClass or all tests depending on where you run it. It seems selecting something inside a single unit test still runs the whole test class.

是否可以运行单个单元测试?

Is it possible to run a single unit test?

我还没有在解决方案资源管理器中右键单击一个文件夹并运行其中的所有测试.

I'm also missing right-clicking a folder in solution explorer and running all the tests in it.

有没有提供这个小功能的扩展程序?

Is there an extension which provides this tiny feature?

推荐答案

CTRL+R, T 被默认分配给 TestExplorer.RunAllTestsInContext.

TestExplorer.RunAllTestsInContext 基于光标的工作方式如下:

TestExplorer.RunAllTestsInContext is works as the following based on the cursor:

所以看起来 TestExplorer.RunAllTestsInContext 就是你正在寻找的......

So it seems that TestExplorer.RunAllTestsInContext is what you are looking for...

要确定可以分配给此功能的键是什么,请单击 Tools ->选项 ->环境 ->键盘,在搜索栏中写:TestExplorer.RunAllTestsInContext 然后你就可以看到keymap/set new one.

To make sure what key may is assign to this feature click on Tools -> options -> Environment -> Keyboard, in the search bar write: TestExplorer.RunAllTestsInContext then you'll be able to see keymap/ set new one.

我还没有在解决方案资源管理器中右键单击一个文件夹并运行其中的所有测试.

I'm also missing right-clicking a folder in solution explorer and running all the tests in it.

有没有提供这个小功能的扩展程序?

Is there an extension which provides this tiny feature?

据我所知,基本上没有这样的工具,因为文件夹对 C# 中的代码没有任何限制.正确的做法是使用`TestCategory 属性.

As I know there is no such a tool basically because folders don't have any restriction on code in C#. The correct way to do such a thing is to use `TestCategory attribute.

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

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