星期二, 2月 26, 2008

使用命令列指令指定測試的Nunit類別

測試程式:

[TestFixture]
public class Class1
{
    [Test, Category("c1")]
    public void test1()
    {
        Console.WriteLine("test1");
    }

    [Test, Category("c2")]
    public void test2()
    {
        Console.WriteLine("test2");
    }

    [Test]
    public void test3()
    {
        Console.WriteLine("test3");
    }

}

 

指令與結果:

C:\Program Files\NUnit 2.4.3\bin>nunit-console.exe c:\temp\cl2\bin\Debug\cl2.dll -include=c1

Included categories: c1
.test1

Tests run: 1, Failures: 0, Not run: 0, Time: 0.078 seconds


C:\Program Files\NUnit 2.4.3\bin>nunit-console.exe c:\temp\cl2\bin\Debug\cl2.dll -include=c1,c2

Included categories: c1,c2
.test1
.test2

Tests run: 2, Failures: 0, Not run: 0, Time: 0.094 seconds

 

C:\Program Files\NUnit 2.4.3\bin>nunit-console.exe c:\temp\cl2\bin\Debug\cl2.dll  -exclude=c1

Excluded categories: c1
.test2
.test3

Tests run: 2, Failures: 0, Not run: 0, Time: 0.078 seconds