2009年10月1日木曜日

NUnitのException

ExceptionはAssert.CatchやAssert.Throwsなどで
Assert.Catch<InvalidOperationException>(()=>{a.func();}, "must throw exception");
のような形でテストできるみたい。
でもNUnitについてくるGUI使うときはこれでもいいけど、
前の日記のようにVisual Studioでやっていると、そこで実行が終わってしまう。

これをやろうとするとやっぱり
try {
   a.func();
   Assert.Fail("must throw exception");
} catch (InvalidOperationException) {
   //OK
}
のようにしないといけないのかな?

0 件のコメント:

コメントを投稿