Joram Visser
03/01/2024, 5:30 PMonNodeWithText("Load").assertDoesNotExist()
onRoot().onChild().onChildAt(0).assertHasClickAction()
onRoot().onChild().onChildAt(0).performClick()
onNodeWithText("Load").assertExists()
Which is not really expressive and sensitive to changes.
Often composables are a little bit more complicated then this example in the blog post:
@Composable
fun MyInfoComposable(info: String, modifier: Modifier) {
Text(modifier = modifier, text = "[IFNO] $info")
}
With this simple example it is nice to set the modifier test tag from the test like
setContent {
MyInfoComposable("Important things!", modifier = Modifier.testTag("info"))
}
But I don’t see how that would work for a Composable consisting out of multiple other Composables.
What would be a good approach for these more complex Composables? Add .testTag("tests-are-interested-in-this")
to the production code?