簡體   English   中英

NUnit:如何僅運行具有特定屬性(優先級或類型)的測試

[英]NUnit: how to run only tests that have specific property (priority or type)

我希望能夠根據多個條件選擇性地運行NUnit測試。 就我而言,選擇將基於:測試優先級和/或測試類型。

測試類/方法如下所示:

namespace NUnit.Tests
{
  using System;
  using NUnit.Framework;

  [TestFixture]
  public class MathTests
  {
    [Test, Property("Priority", "Critical"), Property("Type", "Fully automatic")]
public void AdditionTest()
      { /* ... */ }

    [Test, Property("Priority", "High"), Property("Type", "Partly automatic")]
public void MultiplicationTest()
      { /* ... */ }
  }
}

我只想運行具有“優先級” =“關鍵”和“類型” =“全自動”的測試。

是否可以使用NUnit進行這種選擇? 我知道可以選擇屬於特定“類別”的測試來執行,但這只是1條條件...

根據Nunit控制台手冊

以下命令僅運行“基線”類別中的測試:

nunit-console myassembly.dll / include:數據庫

通過使用逗號將它們分開,可以在任一選項上指定多個類別

因此,我希望像nunit-console myassembly.dll /include:Priority,Critical可以做您想要的事情(我尚未對其進行測試)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM