Skip to content

runTest doesn't time out on Robolectric tests #3173

@1zaman

Description

@1zaman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions