实时单元测试排除测试

实时单元测试排除测试

问题描述:

我知道可以通过右键单击测试项目并选择Live Unit Testing"上下文菜单来从 Live Unit Testing 中排除整个测试项目.

I know it is possible to exclude the whole test project(s) from Live Unit Testing by right clicking on the test project and selecting the "Live Unit Testing" context menu.

但在我的解决方案中,我有一些长时间运行/资源密集型测试,我想排除这些测试.是否可以排除个别测试?

But in my solution I have some long running/resource intensive tests, which I would like to exclude. Is it possible to exclude individual tests?

最简单的方法是右键单击编辑器视图中的方法并选择 Live Unit Testing and Exclude.

Easiest method is right clicking on the method in the editor view and selecting Live Unit Testing and Exclude.

您也可以使用属性以编程方式执行此操作.

You can also do it programatically with attributes.

对于 xUnit:[Trait("Category", "SkipWhenLiveUnitTesting")]

对于 NUnit:[Category("SkipWhenLiveUnitTesting")]

对于 MSTest:[TestCategory("SkipWhenLiveUnitTesting")]

更多信息位于 微软文档