-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Proposal: Make Schedulers should be more friendly to tests #3985
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
Comments
👍 In the long term, I would like to see that |
Actually it wouldn't just be nulling out those fields. It would have to replace the singleton |
@hzsweers That's what I meant :) |
Opened a PR in #3986 for further review |
* Add Schedulers.reset() for better testing Resolves #3985 * More accurate doc
Uh oh!
There was an error while loading. Please reload this page.
RxJavaPlugins.reset()
was recently made public, but there was a common misconception that this would also reset schedulers. This isn't the case however since Schedulers permanently cache their resolved schedulers, soRxJavaPlugins.reset()
actually doesn't help in this regard.I'd like to propose adding a
Schedulers.reset()
function as well. It comes with same caveats thatRxJavaPlugins.reset()
has in that it's dangerous to call in live code, but it would be enormously helpful in testing. This would simply null out the cached schedulers to force a re-check the next time they're used, and thus letting you change the scheduling hook and have the new one's output propagate.With JUnit, it could be nicely wrapped up in a rule that could be optionally dropped into test suites on the fly. Otherwise, schedulers must be set at the beginning of your whole test suite and delegate schedulers put in place that can be configured later.
If people would be open to this, I'd be happy to provide a PR. I looked for prior discussion around this but wasn't able to find any. If I missed them somewhere, please let me know.
The text was updated successfully, but these errors were encountered: