Closed
Description
Example tests recreating issue:
[TestFixture]
public class TestContext_async_issue
{
[Test]
public async Task TestContext_Out_should_flow_with_async_execution()
{
var expected = TestContext.Out;
await Task.Yield();
Assert.AreSame(expected, TestContext.Out);
}
[Test]
public async Task TestContext_CurrentContext_should_flow_with_async_execution()
{
var expected = TestContext.CurrentContext;
await Task.Yield();
Assert.AreSame(expected, TestContext.CurrentContext);
}
}
The side effect of that behaviour is that it is not possible to use TestContext.WriteLine()
after await as it causes NullReferenceException
.
Tested with NUnit 3.5.0
, net46
and netcoreapp1.0