Компонуемый верхнего уровня
Код: Выделить всё
@Composable
fun TopLevelComposable() {
AComposable()
}
Компонуемый дочерний элемент
Код: Выделить всё
@Composable
fun AComposable() {
LeafComposable()
}
Компонуемый лист
Код: Выделить всё
@Composable
fun LeafComposable() {
Text(text = "stringOfText", modifier = Modifier.testTag("Text of AComposable"))
}
MainActivity.kt
Код: Выделить всё
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
TopLevelComposable()
}
}
}
}
java.lang.AssertionError: Failed: assertExists.
Reason: Expected exactly '1' node but could not find any node that satisfies: (TestTag = 'Text of AComposable')
However, the unmerged tree contains '1' node that matches. Are you missing `useUnmergedNode = true` in your finder?
< /code>
Вопрос < /h4>
Как я могу включить AndroidTest принять вложенную .testtag < /code> с использованием композитных? < / п>
Подробнее здесь: https://stackoverflow.com/questions/786 ... in-android
Мобильная версия