Open tomcheung opened 1 year ago
This is expected behavior. A TestScheduler
is not asynchronous. If you need to test asynchronous behavior, you will have to follow the instructions in Asynchronous Tests and Expectations instead of using TestScheduler.
This is the reason (or at least part of the reason) the async producer operators (eg timer
) all accept a Scheduler as a parameter, so you can substitute a TestScheduler and turn them synchronous.
I wonder if the introduction of custom executors in Swift 5.9 will make it possible to force concurrent Swift code to use TestScheduler
.
Short description of the issue:
RxTest TestScheduler didn't work if the observable stream include async await usage (wrapped with AsyncThrowingStream) In some case it will throw
Fatal error: Executing on background thread. Please use MainScheduler.instance.schedule to schedule work on main thread
No matter using
@MainActor
or not, it won't get any value when checking the output from TestableObserverExpected outcome:
Test case run successfully
What actually happens:
Test case got empty event
Self contained code example that reproduces the issue:
RxSwift/RxCocoa/RxBlocking/RxTest version/commit
RxSwift 6.6.0
Platform/Environment
How easy is to reproduce? (chances of successful reproduce after running the self contained code)
Xcode version: