ラベル Exception の投稿を表示しています。 すべての投稿を表示
ラベル Exception の投稿を表示しています。 すべての投稿を表示

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
}
のようにしないといけないのかな?