![](/img/trans.png)
[英]How can I ignore NUnit tests of a certain category while doing a Jenkins build?
[英]How to determine which nunit tests to run or ignore while building in build server
我想指定要在構建服務器中構建項目時運行的測試子集,以便其集成測試運行。
我在這里找到了MSTest
測試的解決方案: 使用DefaultTemplate.xaml忽略TFS構建服務器中的測試類別
但對Nunit無效。
我已經找到Nunit的Category
屬性,但是在構建模板中設置此屬性無效:
Category=IntegrationTest
當我將測試標記為:
[Category("IntegrationTest")]
[TestFixture]
public MyTestClass ...
您可以創建自定義類別(繼承類別類),然后在構建腳本中可以忽略此類別
這是psake + mstest的示例,但可以輕松地應用於NUnit和您使用的任何構建系統
http://log.ld.si/post/longrunningtests-as-a-separate-psake-task
為什么將它們放在同一個項目中? 我建議將集成測試分離到單獨的程序集中。 由於它們是不同的“事物”,因此它們“應該”分開!
我們遇到了同樣的問題,我想出了這個解決方案。 將您的UnitTests放置在一個(或多個)項目中,將IntegrationTests放置在另一個(或多個)項目中。 提示是通過項目名稱來標識其UnitTest或IntegrationTest。 例如,除了其他特定描述外,我們將所有UnitTest項目命名為“ UnitTest”。
然后,在您的builddefinition中,您可以描述過濾器,即buildserver應該使用哪些dll來加載單元測試,並且僅加載文件名中包含UnitTest的dll。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.