如何创建单元测试手动指定时,只运行? [英] How to create unit tests which runs only when manually specified?
问题描述
我记得像明确,而谷歌表示,NUnit的有这样的属性。
是否 Microsoft.VisualStudio.TestTools.UnitTesting 提供了这样的事?
I remember something like 'explicit', and google says that nunit has such attribute. Does Microsoft.VisualStudio.TestTools.UnitTesting provide something like this?
推荐答案
的MSTest的工具不明确支持这种行为的一个属性的水平。在属性级别可以启用通过 TestMethod的
属性的测试或完全与禁用它忽略
属性。一旦忽略
属性添加,直到它被删除MSTest的将不会运行测试。你不能覆盖通过用户界面此行为。
The MSTest tools does not explicitly support this type of behavior at an attribute level. At the attribute level you can either enable a test via the TestMethod
attribute or completely disable it with the Ignore
attribute. Once the Ignore
attribute is added, mstest will not run the test until it is removed. You cannot override this behavior via the UI.
你能做到,虽然是通过属性页禁用测试。打开测试列表编辑器中,选择要测试并按下F4键,弹出属性页。设置测试启用属性设置为false。该测试现在将不会运行,直到通过属性页重新启用它。这不正是你要找的,但可能是最接近的。
What you can do though is disable the test via the property page. Open up the test list editor, select the test you want and hit F4 to bring up the property page. Set the Test Enabled property to false. The test will now not run until you re-enable it through the property page. It's not exactly what you're looking for but likely the closest equivalent.
这篇关于如何创建单元测试手动指定时,只运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!