顯示具有 nunit 標籤的文章。 顯示所有文章
顯示具有 nunit 標籤的文章。 顯示所有文章

星期二, 10月 21, 2008

某些測試在特定機器上老是出現假警報怎麼辦

在指定機器上關掉該假警報測試

[Test]
public void Test(){

if (Environment.MachineName.ToUpper() == "BAD MACHINE")
    Assert.Ignore("this test caused false alarms on BAD MACHINE");

}

星期六, 3月 22, 2008

Nunit中避免category寫錯的小技巧

一般category的使用方式如下:

[Test, Category("IntegrationTest")]
void Test1(){.....}

----------------

一個避免寫錯與免記憶負擔的技巧:

建立一個namespace,內含一些class,用來表示所有測試的category:

namespace TestCategory
{
    class UnitTest : CategoryAttribute { }

    class IntegrationTest : CategoryAttribute { }
}

使用方式:

[Test, TestCategory.IntegrationTest]
void Test1(){.....}