Open raphaelm22 opened 7 months ago
Note to repro'ers: per StackOverflow, you'll need to add public partial class Program {}
at the end of Program.cs, otherwise the reference in TestClass
will bind to an unrelated type and the test won't run properly.
Also, to make the problem a little more explicit, the exception thrown by BeginScope
is the difference between the test failing and waiting indefinitely. The relevant callstack is
> TestProject1.UnitTest1.MyLogger.BeginScope<Microsoft.AspNetCore.Hosting.HostingApplicationDiagnostics.Log.HostingLogScope>(Microsoft.AspNetCore.Hosting.HostingApplicationDiagnostics.Log.HostingLogScope) Line 48 C#
Microsoft.AspNetCore.Hosting.HostingApplicationDiagnostics.BeginRequest(Microsoft.AspNetCore.Http.HttpContext, Microsoft.AspNetCore.Hosting.HostingApplication.Context) Line 116 C#
Microsoft.AspNetCore.Hosting.HostingApplication.CreateContext(Microsoft.AspNetCore.Http.Features.IFeatureCollection) Line 83 C#
Microsoft.AspNetCore.TestHost.ApplicationWrapper<Microsoft.AspNetCore.Hosting.HostingApplication.Context>.Microsoft.AspNetCore.Hosting.Server.IHttpApplication<Microsoft.AspNetCore.Hosting.HostingApplication.Context>.CreateContext(Microsoft.AspNetCore.Http.Features.IFeatureCollection) Line 36 C#
Microsoft.AspNetCore.TestHost.ApplicationWrapper<Microsoft.AspNetCore.Hosting.HostingApplication.Context>.CreateContext(Microsoft.AspNetCore.Http.Features.IFeatureCollection) Line 31 C#
Microsoft.AspNetCore.TestHost.HttpContextBuilder.SendAsync.__RunRequestAsync|0() Line 101 C#
Microsoft.AspNetCore.TestHost.HttpContextBuilder.SendAsync.AnonymousMethod__1(object) Line 163 C#
System.Threading.ThreadPoolWorkQueue.Dispatch() Line 918 C#
System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() Line 102 C#
Is there an existing issue for this?
Describe the bug
The test keeps running when some exception is thrown on the scope log creation (and the test never ends).
Expected Behavior
The HttpClient should return
InternalServerError
.Steps To Reproduce
On
Program.cs
:On TestClass:
Exceptions (if any)
No response
.NET Version
8.0.200
Anything else?
Microsoft Visual Studio Professional 2022 (64-bit) - Preview Version 17.10.0 Preview 1.0