Why does this test always hang when run, but always works in Debug?

49 views Asked by At

Why does the following test hang indefinitely when I run it, but when I debug it, it works perfectly?

[Fact]
public async Task WhyDoesThis_Test_AlwaysHang()
{
    var foo = Console.IsInputRedirected ? await Console.In.ReadToEndAsync() : string.Empty;
    foo.Should().BeEmpty();
}

The actual test executes a library method, but I simplified it for the question as both behave similarly. I am using Rider's default test runner and .NET 8.

The console input is clearly not redirected, so I would expect the test to work without issue, or at least hang in both debug and run modes.

0

There are 0 answers