Skip to content

OneTimeTearDown and Dispose Ordering #2225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mriswyth opened this issue Jun 7, 2017 · 3 comments
Closed

OneTimeTearDown and Dispose Ordering #2225

mriswyth opened this issue Jun 7, 2017 · 3 comments

Comments

@mriswyth
Copy link

mriswyth commented Jun 7, 2017

Using v3.7.0/v3.7.1 from nuget.
Run with NUnit3TestAdapter, NUnit-Gui-0.3, and nunit3-console.

I have some TestFixtures that implement IDisposable. Prior to the v3.7.0 release these test fixtures always executed the OneTimeTearDown (and TestFixtureTearDown before that) method before the TestFixture class' Dispose method. After performing a NuGet update to NUnit v3.7.0 and NUnit v3.7.1 these tests started throwing exceptions in the OneTimeTearDown method as some members had been disposed already.

I was able to reproduce this behavior with the cs-money sample project by having MoneyTest implement IDisposable, add a OneTimeTearDown method, and set breakpoints in each method. NuGet NUnit version before 3.7 execute the OneTimeTearDown method first, 3.7 and 3.7.1 execute Dispose first.

Should I be assuming an ordering of these methods?

@CharliePoole
Copy link
Member

I have confirmed this error by inspecting the code. The commands that make up a test setup are executed in reverse order, whereas one time setup commands are independent and are executed in the order specified in the command list. I updated the list of commands for fixture one-time teardown incorrectly.

I'm assigning this to myself, since I caused it. Too bad we didn't here about this before the hotfix.

@rprouse I'm making this high priority rather than critical. I think only you should decide what's critical and therefore requires a hotfix.

@oznetmaster
Copy link
Contributor

I think it might be critical :(

@CharliePoole
Copy link
Member

It probably is. Sigh.

@rprouse rprouse added this to the 3.8 milestone Jul 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants