如何在Visual Studio测试运行器中排除某些测试? [英] How to exclude certain tests in the Visual Studio Test Runner?

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

问题描述

我对某些测试具有属性,理想情况下,我不想在每个版本上运行.我的大多数测试都是普通的单元测试,我希望它们可以在每个版本上运行.

I have attributes on certain tests that I ideally don't want to run on every build. Most of my tests are normal unit tests and I do want them to run on every build.

所以:如何按类别或项目类型排除测试?

例如,我要排除CodedUItests:

[CodedUITest]
public class SearchViewTests

...或排除给定TestCategory中的测试:

...or exclude tests in a given TestCategory:

[TestMethod]
[TestCategory("Database Integration")]
public void ContactRepositoryGetByIdWithIdExpectCorrectContact()

我特别想排除已编码的UI测试,因为它们会破坏我的继续工作能力,而所有其他测试都将在后台愉快地运行而不会打扰我.

I particularly want to exclude the coded UI tests as they disrupt my ability to continue working, whereas all the other tests will happily run in the background without disturbing me.

最初,这个问题是关于Visual Studio 2012的,所以我更喜欢在该版本及更高版本中可用的解决方案.

Originally this question was about Visual Studio 2012, so I'd prefer solutions that work in that version and higher.

推荐答案

我发现唯一可行的解决方案"(或更优的解决方法)是指定"FullName"过滤器.基本上,我通常会像这样构建我的解决方案

The only "solution" (or better workaround) I found to work is to specify a "FullName" filter. Basically I usually structure my solution like

  • ProjectA
  • ProjectA.UnitTests
  • ProjectA.IntegrationTests

,依此类推.现在,我可以在测试资源管理器中指定一个过滤器,例如FullName: "UnitTests",它似乎可以正常工作.
(我希望能够在搜索名称中使用一个正则表达式,但似乎不受支持.)

and so on. Now I can specify a filter in the Test Explorer like FullName: "UnitTests" which seems to work.
(I'd expected to be able to use a regex within the search name but it doesn't seem to be supported.)

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

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