[Test]
[Ignore("We're skipping this one for now.")]
public void TestOne()
{
// Do something...
}
}
}
如果你想要暫時性的comment out一個test method的話,你應該考慮使用這個attribute。這個attribute讓你保留你的test method,在Test Runner的執行結果里面,也會提醒你這個被略過的test method的存在。
NUnit Assert Class簡介
除了以上所提到的這些用來標示測試程序所在的attributes之外,NUnit還有一個重要的class你應該要知道如何使用。這個class就是Assert class。Assert class提供了一系列的static methods,讓你可以用來驗證主要程序的結果與你所預期的是否一樣。Assert class代替了舊的Assertion class,下面是這個類的方法:
Assert.IsTrue( bool );
Assert.IsFalse( bool );
Assert.IsNull( bool );
Assert.IsNotNull( bool );
Assert.AreSame( object, object )
Assert.AreEqual( object, object );
Assert.AreEqual( int, int );
Assert.AreEqual( float, float, float );
Assert.AreEqual( double, double, double );
文章來源于領測軟件測試網 http://www.kjueaiud.com/