7

/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);
    }
}
}

そして、私のコマンド ライン ステートメントは 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:" でした。マサ」

問題は、コンソールがコマンドの意味に精通しており、Math A カテゴリが含まれていると表示されていることです。ただし、ゼロのテストが実行され、ゼロのテストが実行されていないことを示しています。

コンソールランナーである NUnit 2.6.2 を実行しています。

4

2 に答える 2

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"

個々のテストケースではなく、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"
于 2013-08-14T15:14:56.717 に答える
0

属性を持つクラス全体があるためだと思います:

[Category("MathS")]

だからそれをスキップします。

于 2013-08-13T14:41:40.567 に答える