Using category expressions in a Nunit console runner

I read this link in category expressions when using the / include or / exclude operator. I want to be able to include only a test test, which should be run from two available tests or run all tests, but using / include: A + B or / exclude: A. However, for some reason it displays the wrong number of tests that need to be run and / or not run. Why is this?

Can someone provide me an example of how to express categories (by manipulating the source code) and add how to run the command in the console?

Essentially, I did this:

using System; using NUnit; using NUnit_Application; using NUnit.Framework; namespace NUnit_Application.Test { [TestFixture] [Category("MathS")] public class TestClass { [TestCase] [Category("MathA")] public void AddTest() { MathsHelper helper = new MathsHelper(); int result = helper.Add(20, 10); Assert.AreEqual(40, result); } [TestCase] [Category("MathB")] public void SubtractTest() { MathsHelper helper = new MathsHelper(); int result = helper.Subtract(20, 10); Assert.AreEqual(10, result); } } } 

And my command line expression was nunit-console / framework: net-4.0 / run: NUnit_Application.Test.TestClass.AddTest C: ~ \ NUnit_Application \ NUnit_Application \ NUnit_Application.Test \ bin \ Debug \ NUnit_Application.Test.dll / include: "Matha"

The fact is that the console is familiar with the commands, and it says that it includes the Math A category. However, it shows that the null tests passed and the null tests failed.

I am running NUnit 2.6.2, a console runner.

+7
c # nunit nunit-console
source share
2 answers

Here is the command I used initially:

 nunit-console /framework:net-4.0 /run:NUnit_Application.Test.TestClass.AddTest C:~\NUnit_Application\NUnit_Application\NUnit_Application.Test\bin\Debug\NUnit_Application.Test.dll /include:"MathA" 

I noticed that if I just called TestClass and not a separate test case, it works:

 nunit-console /framework:net-4.0 /run:NUnit_Application.Test.TestClass C:~\NUnit_Application\NUnit_Application\NUnit_Application.Test\bin\Debug\NUnit_Application.Test.dll /include:"MathA" 
+2
source share

I think this is because you have the whole class with the attribute:

 [Category("MathS")] 

So he skips it.

0
source share

All Articles