nunit通过testfixture和test属性的多个类别

时间:2017-10-31 17:25:25

标签: unit-testing testing nunit

[TestFixture(Category = "P1")]
public class TestClass 
{
    [Test(Category = "P2")]
    public void Method()
    {
        //test
    }
}

在上面的代码段中,我们将TestCategory Method视为perl -pi -e 's/oldstring/newstring/' mosi.php :" P1"或" P2"或两者兼而有之?

我想使用该类别来过滤掉测试。

2 个答案:

答案 0 :(得分:1)

目前,您的测试方法仅为P2类。

目前未继承类别。有一些开放的GitHub问题可以在此处更改此行为:https://github.com/nunit/nunit/issues/796和此处:https://github.com/nunit/nunit/issues/1396

答案 1 :(得分:1)

在技术意义上,P1是TestClass的类别,P2是Method的类别。那很清楚。

克里斯指出,类别不是继承的。但是,对于大多数过滤目的而言,这并不重要。

console runner命令行中的以下任一选项都将运行方法:

--where "cat==P1" --where "cat==P2"

以下任何一项都将排除方法

--where "cat!=P1" --where "cat!=P2"

此命令将运行TestClass 中的所有测试,除以外的方法:

--where "cat==P1&&cat!=P2"

IOW,行为类别是继承的,尽管它不是。

相关问题