Skip to content

runTest doesn't time out on Robolectric tests #3173

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

Closed
1zaman opened this issue Feb 5, 2022 · 2 comments
Closed

runTest doesn't time out on Robolectric tests #3173

1zaman opened this issue Feb 5, 2022 · 2 comments
Labels

Comments

@1zaman
Copy link
Contributor

1zaman commented Feb 5, 2022

Since Robolectric loads fake implementations of Android framework classes, including Looper and Handler, which are responsible for running the main thread, a main dispatcher is loaded based on these classes. Since the main dispatcher is now used as the default delay controller, this causes the runTest timeout to be controlled by the fake main thread implementation as well, which results in the test timeout not working.

The same thing happens if a test dispatcher is set as the main dispatcher using the Dispatchers.setMain method in a Robolectric test. In that case, the test dispatcher becomes responsible for controlling the delay, which again results in the timeout not working.

@dkhalanskyjb
Copy link
Collaborator

We already rolled back the "Main controls all delays" change: 9169d09, so this will not be an issue in the subsequent releases. You can already set the kotlinx.coroutines.main.delay system property to false to get rid of such behavior in advance.

@dkhalanskyjb
Copy link
Collaborator

Should have been fixed in 1.6.1. Please reopen if it hasn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants