alorma
09/08/2021, 11:13 AM@Composable but they need some composable code... code in 🧵alorma
09/08/2021, 11:13 AM@Test
fun assertIsDisplayed_ResourceTest() {
val textRes = R.string.app_name
composeTestRule.setContent {
val text = stringResource(id = textRes)
TextComposable(text = text)
}
composeTestRule.assertIsDisplayed(text = textRes)
}alorma
09/08/2021, 11:14 AM@Composable
fun ComposeTestRule.assertIsDisplayed(
useUnmergedTree: Boolean = false,
@StringRes text: Int,
substring: Boolean = false,
ignoreCase: Boolean = false
): SemanticsNodeInteraction {
return onNodeWithText(
text = stringResource(id = text),
substring = substring,
ignoreCase = ignoreCase,
useUnmergedTree = useUnmergedTree
).assertIsDisplayed()
}alorma
09/08/2021, 11:14 AM@StringRes as a param, I need to use stringResource() to load it as String but for that i need the @Composable annotationalorma
09/08/2021, 11:15 AMjava.lang.Exception: Method assertIsDisplayed_ResourceTest should have no parametersalorma
09/08/2021, 12:22 PM