[この記事は19年前に書かれました]
特定の例外が発生することをテストするには「ExpectedException」属性を使用する。
[TestFixture]
public class TestClass
{
[Test]
[ExpectedException(typeof(TestExcption))]
public void ConstructorTest()
{
Test test = new Test(3);
}
}
上記の場合だと、TestExcptionが発生するとテストは成功。


コメント