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

Custom Thread #59

Open akblissweb opened 2 years ago

akblissweb commented 2 years ago

Hi,

We have a custom thread, which have made which is similar to the WinForms UI thread. It involves wrapping all tests with something like:

using var dispatcher = new CustomDispatcher();
await dispatcher.InvokeAsync(() =>
{
     [Original Test Code]
}

What would be the best way to extend your package here ? Or is there a simpler way in Xunit to get this functionality ?

Thanks

AArnott commented 2 years ago

Interesting. I imagine we could make this library accept a custom dispatcher, such that you could write your own Fact-derived attribute that creates the dispatcher and this library does the heavy lifting for you. In fact we kinda already have that model since we run tests at least 3-4 ways and share some code.

Wanna take a look and see what changes would make sense and we can discuss?