[英]Multiple categories for nunit through testfixture and test attributes
[TestFixture(Category = "P1")]
public class TestClass
{
[Test(Category = "P2")]
public void Method()
{
//test
}
}
在上面的代码片段中,什么将被视为Method
的TestCategory
:“ P1”或“ P2”或两者兼而有之?
我想使用类别来过滤掉测试。
当前,您的测试方法将仅是类别P2。
当前未继承类别。 此处存在开放的GitHub问题来更改此行为: https : //github.com/nunit/nunit/issues/796和此处: https : //github.com/nunit/nunit/issues/1396
从技术上讲,P1是TestClass的类别,P2是Method的类别。 很清楚
克里斯指出,类别不是继承的。 但是,对于大多数过滤目的而言,这对您而言并不重要。
控制台运行程序命令行上的以下任何一个选项都将运行Method:
--where "cat==P1" --where "cat==P2"
以下任一情况都将排除方法
--where "cat!=P1" --where "cat!=P2"
此命令将运行TestClass中的所有测试(方法除外) :
--where "cat==P1&&cat!=P2"
IOW,它的作用就像继承了类别,尽管不是。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.