AArnott / Xunit.StaFact

Run your xunit-based tests on an STA thread with the WPF Dispatcher, a WinForms SynchronizationContext, or even a cross-platform generic UI thread emulation with a SynchronizationContext that keeps code running on a "main thread" for that test.
Other
92 stars 31 forks source link

Include owning test name in exception when zombied SyncContext is used #56

Closed lg2de closed 2 years ago

lg2de commented 2 years ago

report the name of the thread if UISynchronizationContext is invoked and pump already ended

lg2de commented 2 years ago

I was not able to run the tests locally. The CI build seems not to work for PRs :(

We are facing issues with tests failed with

### error output ###
The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.InvalidOperationException: The message pump isn't running any more.
   at Xunit.Sdk.UISynchronizationContext.Post(SendOrPostCallback d, Object state)
   at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore`1.InvokeContinuation()
   at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore`1.SignalCompletion()
   at System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore`1.SetResult(TResult result)
   at System.Threading.Channels.ChannelReader`1.ReadAllAsync(CancellationToken cancellationToken)+MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.ExecutionContextCallback(Object s)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext()
   at System.Threading.ThreadPoolGlobals.<>c.<.cctor>b__5_0(Object state)
   at System.Threading.Channels.AsyncOperation`1.SetCompletionAndInvokeContinuation()
   at System.Threading.Channels.AsyncOperation`1.System.Threading.IThreadPoolWorkItem.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

We would like to know which test causes the problem. What do you think @AArnott ?

AArnott commented 2 years ago

/azp run

azure-pipelines[bot] commented 2 years ago
Azure Pipelines successfully started running 1 pipeline(s).
lg2de commented 2 years ago

Thanks for your fast response. We have identified the failing tests with this extension. :)

Could you please create a public (non-alpha) release?

AArnott commented 2 years ago

Watch for 1.1.10 to push to nuget.org in the next hour.

AArnott commented 2 years ago

Make that 1.1.11.