Skip to content
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

Catch uncaught RxJava errors in unit tests #438

Merged
merged 3 commits into from
Jan 8, 2019

Conversation

saket
Copy link
Contributor

@saket saket commented Jan 4, 2019

Starting from RxJava2, uncaught errors are not thrown but instead sent to the thread's default error handler. This results in a situation where JUnit would always pass even if any RxJava chain encounters an error.

More information here: ReactiveX/RxJava#5234

This commit introduces a JUnit rule that observes uncaught errors, but it needs to be manually added to every test. The rule was copied from AutoDispose.

@saket saket added the work in progress Feature isn't complete and the PR shouldn't be merged yet label Jan 4, 2019
@saket saket force-pushed the sn/04jan/catch-swallowed-rx-errors branch from 97a703f to e545244 Compare January 4, 2019 12:18
@saket saket removed the work in progress Feature isn't complete and the PR shouldn't be merged yet label Jan 4, 2019
@saket saket force-pushed the sn/04jan/catch-swallowed-rx-errors branch from e545244 to 75b9f45 Compare January 4, 2019 12:19
@saket saket force-pushed the sn/04jan/catch-swallowed-rx-errors branch 2 times, most recently from 3b41902 to a322f4b Compare January 7, 2019 09:03
@saket
Copy link
Contributor Author

saket commented Jan 7, 2019

@vinaysshenoy feedback addressed.

@saket saket force-pushed the sn/04jan/catch-swallowed-rx-errors branch 2 times, most recently from 2a3f3c2 to 6522b89 Compare January 7, 2019 12:21
Saket Narayan added 3 commits January 8, 2019 12:01
Starting from RxJava2, uncaught errors are not thrown but instead sent to the thread's default error handler. This results in a situation where JUnit would always pass even if any RxJava chain encountered an error.

This commit introduces a JUnit rule that observes uncaught errors, but it needs to be manually added to every test.
This also includes making jUnit library available to main source set and not just tests. This was done so that RxErrorsRule can be shared between unit tests and Android tests.
@saket saket force-pushed the sn/04jan/catch-swallowed-rx-errors branch from 6522b89 to 7f31a94 Compare January 8, 2019 06:31
@vinaysshenoy vinaysshenoy merged commit e39b130 into master Jan 8, 2019
@vinaysshenoy vinaysshenoy deleted the sn/04jan/catch-swallowed-rx-errors branch January 8, 2019 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants