Compose testing click registration fails when doubleClick is present
08:14 01 Sep 2026

I want to test if clicks, doubleclicks and longpresses are registered correctly on my custom composables. Some tests succeed, and some fail without apparent reason. So I simplified everything to this:

The composable under test:

@Composable
    fun ComposableToTest(
        modifier: Modifier = Modifier,
        onComposableClick:()->Unit = {}
    ){
        Text(
            text = "testing this",
            modifier = Modifier
                .pointerInput(Unit){
                    detectTapGestures (
                        onTap= {onComposableClick()},
                        onDoubleTap = {onComposableClick()}, <--present,test fails
                        onLongPress = {onComposableClick()}    not present, succes
                    )
                }
        )
    }

To assert the onComposableClick function I created an helper class

class HelperFunction{
    fun returnEvent(){
        Timber.d("text clicked")
    }
}

In the test the helperclass is mocked to verify if the function is called.

val mockTestFunction = mockk{
        every { returnEvent()  } just Runs
    }

    @Test
    fun testClickonText(){
        composeTestRule.setContent {
            ComposableToTest(onComposableClick = {mockTestFunction.returnEvent()})
        }

        composeTestRule.onNodeWithText("testing this").performTouchInput { click(Offset(5f,5f)) }

        verify { mockTestFunction.returnEvent() }
    }

This test fails although in my opinion it should not.

If I comment out the onDoubleTap in detectTapGestures the test succeeds.

The same happens if I use

modifier = Modifier
                .combinedClickable(
                    onClick = {onComposableClick()},
                    onDoubleClick = {},
                    onLongClick = {}
                )

with onDoubleClick the test fails, without it the tests succeeds.

How do I write my test so the click event as well as the doubleclick are recognized?

unit-testing android-jetpack-compose