I would like to run a small set of NUnit test cases as a test to test before validation, as well as a more complete set of test cases for my checks and nightly tests.
Thus, I was hoping that I would be able to decorate certain cases of tests with the βCategoryβ attribute and have only those test cases that are executed during the preliminary test. However, this does not work - if I include a category, then all test cases are executed.
Is there a way to limit the number of test cases run through categories?
[TestFixture] public class TestAddition { [TestCase(1, 2, 3), Category("PreCheckin")] [TestCase(2, 4, 6)] [TestCase(3, 6, 9)] public void AdditionPassTest(int first, int second, int expected) { var adder = new Addition(); var total = adder.DoAdd(first, second); Assert.AreEqual(expected, total); } }
If I try to run this:
C:\> "C:\Program files (x86)\Nunit 2.6.4\bin\nunit-console.exe" /nologo ^ NUnitTestCase.dll /labels /include=PreCheckin ProcessModel: Default DomainUsage: Single Execution Runtime: net-3.5 Included categories: PreCheckin ***** NUnitTestCase.TestAddition.AdditionPassTest(1,2,3) ***** NUnitTestCase.TestAddition.AdditionPassTest(2,4,6) ***** NUnitTestCase.TestAddition.AdditionPassTest(3,6,9) Tests run: 3, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.0743007328107035 seconds Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
I needed to run only one test case (1, 2, 3)