-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stream tests lack time manipulation #695
Comments
You can actually use fake time already, most of the tests actually use fake async. On my phone atm, but please take a look at the runZoned api in Dart, for example, which allows you to override timers. |
I took a look at the source code for some streams and I can see it uses very small durations, so I assumed there was no way to inject a fake time. |
Maybe cause they're already quite old then, it's been a while since I've contributed to this lib actually. I'd try a simple case with a Zone and some Rx, if it doesn't work we could always update the inner parts, basically it should rely on the wrapping zones for timings |
I think we can use clock package in rxdart, but some built-in Stream constructors don't receive any schduler, such as Stream.periodic Sent from my 2201117TG using FastHub |
I think tests should be easy to setup, zones can get cumbersome to manipulate. The clock package should be better IMO. |
Also, I don't think we should reinvent the wheel, studying how RxJava solves this should be better, as the mechanism probably covers lots of use cases for asynchronous testing of reactive streams. |
RxJava has the ability to inject a scheduler to some streams, this way we can manipulate time in tests. If I have an
interval
of 5 minutes in my code, I can't test it without a very long test, or by changing myinterval
in the test to some milliseconds, which won't simulate 100% what's happening in the app.The same way that Flutter tests allows us to manipulate time for testing animations, without having to actually wait for them, rxdart should give us similar controls, as other rx libraries already do.
The text was updated successfully, but these errors were encountered: