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...
There is no facility in NUnit to order tests globally. Tests with an OrderAttribute argument are started before any tests without the attribute. Ordered tests are started in ascending order of the order argument. Among tests with the same order value or without the attribute, execution order is indeterminate.
This attribute is used inside a TestFixture to provide a common set of functions that are performed just before each test method is called.
IgnoreAttribute (NUnit 2.0) The ignore attribute is an attribute to not run a test or test fixture for a period of time. The person marks either a Test or a TestFixture with the Ignore Attribute. The running program sees the attribute and does not run the test or tests.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With