3

現在、テストメソッドによって生成されたスレッドで例外が発生した場合にテストが失敗することを確認する方法を見つけようとしています。

単体テストで複数のスレッドについて議論を始めたくありません。=> "ユニットテスト".Replace("ユニット","統合");

CrossThreadTestRunnerについては知っていますが、nunit に統合され、多くのテストを書き直す必要のないソリューションを探しています。

4

3 に答える 3

3

The reason that exceptions on non-test threads (i.e. other spawned threads) do not cause tests to fail is that NUnit is configured by default to use legacyUnhandledExceptionPolicy which is a .Net process level setting which can be applied via app.config, i.e.:

<legacyUnhandledExceptionPolicy enabled="1"/>

Enabling this setting (i.e. setting it to "1") causes exceptions which do not occur on the main thread to be ignored.

I wrote an article which goes into more detail in reference to this issue with the ReSharper test runner, but it applies equally to the NUnit test runner:

http://gojisoft.com/blog/2010/05/14/resharper-test-runner-hidden-thread-exceptions/

于 2010-07-23T15:50:47.060 に答える
-8

ITestDecorator を「インストール」する nunit のアドインを作成することで、この問題を解決しました。

于 2008-12-10T11:27:41.967 に答える