Fix: non-async tests hang sometimes when UIThread = true#26
Fix: non-async tests hang sometimes when UIThread = true#26
Conversation
|
It might be worth considering an alternative where the test is immediately reported as failing if it's a UI thread test but isn't |
|
Apparently Task taskFromResult = GetTaskFromResult(CallTestMethod(testClassInstance));
if (taskFromResult != null)
await taskFromResult;
else
{
Exception ex = await asyncSyncContext.WaitForCompletionAsync();
} |
|
It's interesting that xunit has a way to run |
|
Agree I just wanted to point out that it didn't work since my pull request didn't account for it. I'm still not sure whether we shouldn't allow synchronous UI tests to just work. It's much simpler to play with this library if it does, and I'm guessing there are still methods that just call Should those be avoided if possible by the way? I'm just making them |
|
💭 If you want to undo the Where |
|
Not sure if that helps or not. |
Xunit.Sdk.AsyncTestSyncContextseems to be the problem and it's only purpose is to supportasync voidtest methods.So the problem is solved if we dodge it when the test method is not
asyncandUIThread = true.