NUNIT を使用してこのテスト ケースを実行し、NUNIT を Visual Studio デバッガーにアタッチしています (デバッグ ---> プロセスにアタッチ ---> nunit.exe を選択)。
"throw new Exception("Exception 1 occured!");" ステートメントがコントロールを catch ブロックに移動することを期待していましたが、コントロールは "catch" にジャンプせず、代わりに method2() にジャンプします。
nunit.exe を Visual Studio デバッガーにアタッチせずに nunit テスト ケースを実行すると、コードは正常に動作します。
public void test()
{
try
{
method1();
if (condition1)
{
throw new Exception("Exception 1 occured!");
}
method2();
if (condition2)
{
throw new Exception("Exception 2 occured!");
}
method3();
if (condition3)
{
throw new Exception("Exception 3 occured!");
}
}
catch (Exception Ex) <---- Exceptions thrown above are caught here
{
logMessage(E.Message);
throw;
}
}