[英]How to run a single test or all tests in a specific folder in Visual Studio?
So I'm moving from Visual Studio 2015 with ReSharper to Visual Studio 2017 and I'm trying to remove ReSharper from my workflow. 因此,我将从使用ReSharper的Visual Studio 2015迁移到Visual Studio 2017,我正在尝试从我的工作流程中删除ReSharper。
I know what CTRL+R,T runs either a whole TestClass or all tests depending on where you run it. 我知道什么是CTRL + R,T运行整个TestClass或所有测试,具体取决于你运行它的位置。 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
is by defualt is assign to TestExplorer.RunAllTestsInContext
. CTRL+R, T
由defualt分配给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... 所以似乎
TestExplorer.RunAllTestsInContext
就是你要找的......
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. 要确保分配给此功能的键,请单击
Tools -> options -> Environment -> Keyboard
,在搜索栏中写入: TestExplorer.RunAllTestsInContext
然后您将能够看到键映射/设置新键。
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?
有没有提供这个小功能的扩展?
As I know there is no such a tool basically because folders don't have any restriction on code in C#. 据我所知,基本上没有这样的工具,因为文件夹对C#中的代码没有任何限制。 The correct way to do such a thing is to use ` TestCategory attribute .
执行此类操作的正确方法是使用` TestCategory属性 。
You can run a single unit test from the Tests Explorer
window. 您可以从“
Tests Explorer
窗口运行单个单元测试。 When you have done it once, you can rerun the last tests run using Ctrl+R, L
. 完成一次后,可以使用
Ctrl+R, L
重新运行最后一次测试。 So if the last run you have done is a single unit test, it will be the only one to be rerun. 因此,如果您最后一次运行是单个单元测试,那么它将是唯一一个重新运行。 Sadly, it seems there is no shortcut to run the unit test under cursor.
可悲的是,似乎没有在光标下运行单元测试的捷径。
Regarding the other part of your question, with the Tests Explorer
window you can have tests grouped by namespace, project, class or result and then run all tests of a specific group. 关于问题的其他部分,使用“
Tests Explorer
窗口,您可以按命名空间,项目,类或结果分组测试,然后运行特定组的所有测试。 Maybe it can fit our needs? 也许它可以满足我们的需求?
Hope this help. 希望这有帮助。
In the TestExplorer
you can group tests by Class
(there is a Group By
button in the toolbar as shown in the image) then it will group tests by their classes and you can right-click on a group an click Run Selected Tests
. 在
TestExplorer
您可以按Class
测试进行分组(工具栏中有一个Group By
按钮,如图所示)然后它将按类对测试进行分组,您可以右键单击一个组,然后单击Run Selected Tests
。
You can have a new filter criteria in the search box of test explorer . 您可以在test explorer的搜索框中使用新的过滤条件。 In the filter drop down , you can select a full name option and there you can give your namespace .
在过滤器下拉列表中,您可以选择全名选项,然后您可以在其中提供命名空间。
It will list entire test files located under that namespace. 它将列出位于该命名空间下的整个测试文件。 You can then select all of the test file and do "Run selected tests".
然后,您可以选择所有测试文件并执行“运行选定的测试”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.