Reputation: 40549
If I create an IDisposable during the TestFixtureSetup of an NUnit test, and the test throws an unanticipated exception (e.g. external resource fails), will the IDisposable's Dispose() get called?
Added>>
If not, does NUnit provide guaranteed execution of TestFixtureTearDown or somewhere else that can be used for cleanup?
Upvotes: 4
Views: 1201
Reputation: 1039318
No it won't be called. IDisposable is used for deterministic finalization usually used in conjunction with the using
statement. You could call the Dispose method in the TestFixtureTearDown
though.
Upvotes: 6