在Nunit控制台运行器中使用类别表达式

Kal*_*a J 7 c# nunit nunit-console

在使用/ include或/ exclude语句时,我正在阅读关于类别表达式的链接.我希望能够仅包括运行测试以用于两个可用的测试或运行所有测试但使用/ include:A + B或/ exclude:A.但是,由于某种原因,它显示了要运行和/或未运行的错误测试数.这是为什么?

任何人都可以提供一个关于如何分类表达式(通过操作源代码)并添加如何在控制台中运行命令的示例?

基本上我做的是:

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);
    }
}
}
Run Code Online (Sandbox Code Playgroud)

我的命令行语句是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:"玛莎"

问题是,控制台熟悉命令的含义,并说它包含数学A类.但是,它表明已经运行了零测试,并且没有运行零测试.

我正在运行NUnit 2.6.2,即控制台运行程序.

Kal*_*a J 2

这是我最初使用的命令:

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"
Run Code Online (Sandbox Code Playgroud)

我注意到如果我只调用 TestClass 而不是单个测试用例,它会起作用:

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"
Run Code Online (Sandbox Code Playgroud)