ASP.NET integration testing leads to garbled logs
Hello. Great, great project.
In ASP.NET Core (at least 5 and up), when integration testing with the WebApplicationFactory ExecutionContext is not preserved across calls to the TestServer.
This leads to some garbled log outputs that are super hard to debug. Because any log outputs from IHostedService and in the Startup of the server has the "correct" ExecutionContext and so is logged to XUnitContext, but anything after that (such as controller calls) do not.
Turns out that there's a boolean switch on the TestServer that's pretty hard to find and that tells whether or not to preserve the ExecutionContext
I think we should document this so nobody else spends a few hours troubleshooting this.
I have added a PR that documents the steps I took to make logging work.