-
Notifications
You must be signed in to change notification settings - Fork 733
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
NUnit should support async setup, teardown, fixture setup and fixture teardown #60
Comments
There is currently no support for async setup, teardown, fixture setup or fixture teardown. In the example you give, the call returns before any code is even executed, so NUnit has no awareness of the exception being thrown. Obviously, one would normally avoid use of async on any of these methods, but it is conceivable that they need to call other async methods and you might be forced to use it in the signature. It seems to me that the desired behavior on NUnit's part is to wait for the methods to complete, rather than to continue to fire off other methods. I'm changing the title of the bug accordingly. |
The following signature gives me "Ignored: Invalid signature for SetUp or TearDown method", but I had hoped returning Task would help NUnit understand it was awaitable as explained in http://simoneb.github.io/blog/2013/01/19/async-support-in-nunit/ . [TestFixtureSetUp]
public async Task FixtureSetUp() {} |
Nope. There's no support. If you read Simone's post closely, you'll see he only talks about test methods. Support for async test methods is also present in NUnit 3.0, where it's a bit more complex, since we may start other test methods while waiting. SetUp, TearDown, etc. are simpler in fact but still have to be implemented at the point where those calls are made. Charlie |
Marking this review so we can decide what action to take. |
I just read about the support for Proper |
This is still under review - which means we are deciding whether to do it at all. It would help if you had a motivating example for us, showing why a SetUp needs to be async. |
My thoughts would not be so much what can't be done without async (we would all code in assembly language by that rationale), but more that users, including myself, intuitively expected that this feature would be available and were confused and wasted time when SetUp didn't work the same way as the rest of the API, which does support async. I think that support for async SetUp and TearDown should be provided for similar reasons to why async tests are supported - it allows us to write clean, idiomatic, async code without having to sprinkle Less WTF moments and cleaner code leads to happier users. |
What @nzbart said. The use case is simple: Creating a It wouldn't be so bad if |
Thanks, that's helpful.
|
OK, based on the comments and our review, we'll accept this change as a new enhancement. We will at least allow SetUp, TearDown, OneTimeSetUp and OneTimeTearDown to be async. We'll have to do a little analysis to figure out whether other user code that we call can also be async without adverse side effects. Other examples of user code would inclued a method that provides data for a test or the code executed by an action attribute. Where possible, we should allow these to be async. If it turns out to not be possible, we should give some kind of error or warning message. |
👍 |
Are there any updates on this issue? |
@davidpeden3, This issue has been assigned to a developer and assigned to the 3.0 release, so we have committed to it, but AFAIK, it hasn't been worked on yet. |
@rprouse Great, thanks for the quick update. |
Would also like to see this feature. |
Update supported framework runtime attribute to exclude maxversion, so that it is not restricted to current .net Version. Also work around a current VS CTP5 bug which prevents loading of vsix now.
This does not work as expected. Tests are still run as if fixture setup was OK.
This works as expected. Tests are not run and exception is written to test output.
Only relevant for .NET 4.5 and later, which supports await/async C# identifiers.
The text was updated successfully, but these errors were encountered: