[FIXED] Compose android testing fails: Idling resource timed out


I’m trying to write the test for my composes. So I have a test class put in AndroidTest just like this:

@UninstallModules(AuthenticationModule::class, AppModule::class)
class AuthenticationScreenTest {

    @get:Rule(order = 0)
    val hiltRule = HiltAndroidRule(this)

    @get:Rule(order = 1)
    val composeRule = createAndroidComposeRule<MainActivity>()

    lateinit var setting: Setting

    fun setup() {
        composeRule.setContent {
            val navController = rememberNavController()
            RefectoryTheme {
                    navController = navController,
                    startDestination = AuthenticationNavGraph.AuthenticationScreen.route
                ) {
                    composable(AuthenticationNavGraph.AuthenticationScreen.route) {
                        AuthenticationScreen(navController = navController, setting = setting)

    fun checkLoadingButtonExpantion() {
        composeRule.onNodeWithTag(testTag = AUTHENTICATION_SCREEN_LOGIN_BUTTON)

but I keep getting the error:

androidx.compose.ui.test.junit4.android.ComposeNotIdleException: Idling resource timed out: 
possibly due to compose being busy.
IdlingResourceRegistry has the following idling resources registered:
- [busy] androidx.compose.ui.test.junit4.ComposeIdlingResource@a005df5
All registered idling resources: Compose-Espresso link

The android emulator is launched, test compiles successfully, but it seems it can’t find the object.
I also have added a test tag to the modifier of the object:

                    buttonText = stringResource(id = R.string.login),
                    isExpanded = state.isLoginExpanded,
                    modifier = Modifier
                ) {

But after 28 seconds, I got the error as mentioned above.
What am I missing?


I just realized what the problem was.
I am using Lottie on my screen, and the animation is infinity repeating.
So I don’t know why but it seems that it doesn’t allow testing to go through.
The tests ran without any problem when I commented the Lottie section.

Answered By – Mohammad Derakhshan

Answer Checked By – Laura B. (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published