-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
When calling an async void method or delegate, the method runs in the background and the current method continues without having a chance to observe its result.
[Test]
public static void NonAsyncTestCallingAsyncVoidMethod()
{
AsyncVoidMethod();
}
private static async void AsyncVoidMethod()
{
await Task.Delay(10);
throw new InvalidOperationException("Exception from inside async void method.");
}NUnit will think that the NonAsyncTestCallingAsyncVoidMethod has finished before the exception is thrown in the async void method.
Once the exception is thrown in an unexpected place, it could crash NUnit (pre NUnit 4.5) or catch it and mark the test as Error.
But if the time between the exception and the test 'finishing' is too small, nunit could have marked the test as Success prematurely.
See: nunit/nunit#3930
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels