Alex C
11/04/2021, 12:03 AMval testData = listOf("item1", "item2", "item3")
composeTestRule.setContent {
LazyColumn(Modifier.testTag(TEST_TAG)) {
itemsIndexed(testData) { index, item ->
Row {
Text("index $index: ")
Spacer(modifier = Modifier.height(10.dp))
Text(item)
}
}
}
}
composeTestRule.onNodeWithTag(TEST_TAG).onChildren().assertCountEquals(3)
It turns out the actual count of the children is 6 rather than 3, which counts the Text("index $index: ")
and Text(item)
inside the Row but not the Spacer()
But what I actually want is to count how many rows in the LazyColumn.
So how can I do it?Alex C
11/04/2021, 12:41 AMAlex C
11/04/2021, 1:27 AMAlex C
11/04/2021, 1:51 AMJohn Nichol
11/05/2021, 3:23 PM