[英]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.