NUnit tests: is IDisposable guaranteed when an unexpected exception occurs?

If I create an IDisposable during the TestFixtureSetup of the NUnit test and the test throws an unexpected exception (for example, an external resource failed), is IDisposable Dispose () called?

Added →
If not, does NUnit guarantee the execution of TestFixtureTearDown, or somewhere else that can be used for cleanup?

+4
source share
1 answer

No, he will not be called. IDisposable is used for deterministic finalization, commonly used in conjunction with using . You could call the Dispose method in TestFixtureTearDown .

+6
source

Source: https://habr.com/ru/post/1313866/


All Articles