andrey1492
andrey1492

Reputation: 483

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

I want to have the ability to selectively run the NUnit tests based on several criteria. In my case, the selection will be based on: Test Priority and/or Test Type.

The test class/method would look like that:

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()
      { /* ... */ }
  }
}

I want to run only the tests that have "Priority" = "Critical" AND "Type" = "Fully automatic".

Is it possible to implement such selection with the NUnit? I know it is possible to select tests belonging to specific "categories" for execution, but it is only 1 criterion...

Upvotes: 8

Views: 3499

Answers (1)

gbanfill
gbanfill

Reputation: 2216

According to the Nunit Console Manual:

The following command runs only the tests in the BaseLine category:

nunit-console myassembly.dll /include:Database

Multiple categories may be specified on either option, by using commas to separate them.

So I would expect something like nunit-console myassembly.dll /include:Priority,Critical to do what you want (I havent tested it).

Upvotes: 3

Related Questions