Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing MsTest单元测试可以按类别分组吗_Unit Testing_Mstest_Mbunit - Fatal编程技术网

Unit testing MsTest单元测试可以按类别分组吗

Unit testing MsTest单元测试可以按类别分组吗,unit-testing,mstest,mbunit,Unit Testing,Mstest,Mbunit,在MbUnit中,可以执行以下操作: [Test] [TestCategory("Bad Arguments")] [TestCategory("Fast")] [ExpectedException(typeof(ArgumentNullException))] public void TestCopyWithBadHref() { . . . } [Description("test 123456"), TestCategory("Edit Tests"), TestCategory

MbUnit
中,可以执行以下操作:

[Test]
[TestCategory("Bad Arguments")]
[TestCategory("Fast")]
[ExpectedException(typeof(ArgumentNullException))]
public void TestCopyWithBadHref()
{
   . . . 
}
[Description("test 123456"), TestCategory("Edit Tests"), TestCategory("Non-Smoke"), TestMethod]
public void VerifyEditsPersist()
请注意以下两点:

[TestCategory("Bad Arguments")]
[TestCategory("Fast")]
由于TeamBuild可以与MsTest集成以执行门控签入和/或在夜间运行,因此它是一个很棒的功能!但是,由于某些测试可能会运行很长时间,因此可以方便地将它们分为在确认每次签入之前应运行的测试和应在夜间运行的测试,因为它们的持续时间以及其他因素

实现这一点的一种方法可能是创建几个项目——一个用于慢速测试,一个用于快速测试,等等。但是,这种分离很不方便。项目依赖关系不会让人感觉很自然,另外一些测试可以在多个逻辑类别中进行

如果MsTest拥有与MbUnit长期以来所拥有的类似的功能,那将是一件非常棒的事情。例如,可以运行
MbUnit.Cons.exe
并指定要与命令行开关一起使用的类别


如何使用
MsTest
达到同样的效果?我们是一家MSFT商店,我未能将MbUnit出售给我的同事。

您可以使用/category选项筛选VS 2010中的测试

它使用。详细资料

C#代码可能如下所示:

[Test]
[TestCategory("Bad Arguments")]
[TestCategory("Fast")]
[ExpectedException(typeof(ArgumentNullException))]
public void TestCopyWithBadHref()
{
   . . . 
}
[Description("test 123456"), TestCategory("Edit Tests"), TestCategory("Non-Smoke"), TestMethod]
public void VerifyEditsPersist()

这个属性在C代码中是什么样子的?您有我可以学习的示例或链接吗?是否可以在visual studio中打开.testsettings配置文件以运行具有特定类别的测试,或按类别跳过特定测试?我知道这是可以从命令行执行的。。。但是从IDE呢?在测试视图中,您可以根据类别过滤测试