Cedric Lindigkeit
10/20/2022, 9:17 AMClickableText(
text = "Awesome text",
modifier = Modifier.testTag("SOME_TEST_TAG"),
onClick = { ... }
)
ErrorMessage:
Failed to assert the following: (OnClick is defined)
Reason: Expected exactly '1' node but could not find any node that satisfies: (TestTag = 'SOME_TEST_TAG')
However, the unmerged tree contains '1' node that matches. Are you missing `useUnmergedNode = true` in your finder?
czuckie
10/20/2022, 11:55 AMcomposeTestRule.onRoot().printToLog()
Cedric Lindigkeit
10/20/2022, 1:44 PMcomposeRule.onRoot().printToLog()
threw a NotImplementedException
I used .printToString()
which resulted in the following output:
Printing with useUnmergedTree = 'false'
Node #1 at (l=0.0, t=0.0, r=1024.0, b=768.0)px
|-Node #2 at (l=980.0, t=0.0, r=1024.0, b=44.0)px, Tag: 'TAG_A'
| Focused = 'false'
| Actions = [OnClick]
| MergeDescendants = 'true'
|-Node #5 at (l=332.0, t=285.0, r=692.0, b=332.0)px
| Text = 'TEXT_A'
| Actions = [GetTextLayoutResult]
|-Node #6 at (l=426.0, t=348.0, r=598.0, b=364.0)px
| Text = '[Add your first photo source:]'
| Actions = [GetTextLayoutResult]
|-Node #7 at (l=312.0, t=388.0, r=400.0, b=476.0)px
| |-Node #8 at (l=312.0, t=388.0, r=400.0, b=476.0)px, Tag: 'TAG_B'
| Focused = 'false'
| Text = 'TEXT_B'
| Actions = [OnClick, GetTextLayoutResult]
| MergeDescendants = 'true'
|-Node #12 at (l=416.0, t=388.0, r=504.0, b=476.0)px
| |-Node #13 at (l=416.0, t=388.0, r=504.0, b=476.0)px, Tag: 'TAG_C'
| Focused = 'false'
| Text = 'TEXT_C'
| Actions = [OnClick, GetTextLayoutResult]
| MergeDescendants = 'true'
|-Node #17 at (l=520.0, t=388.0, r=608.0, b=476.0)px, Tag: 'TAG_D'
| Focused = 'false'
| Text = 'TEXT_D'
| Actions = [OnClick, GetTextLayoutResult]
| MergeDescendants = 'true'
|-Node #21 at (l=144.0, t=724.0, r=220.0, b=768.0)px, Tag: 'TAG_E'
| Focused = 'false'
| Text = 'TEXT_E'
| Actions = [OnClick, GetTextLayoutResult]
| MergeDescendants = 'true'
|-Node #25 at (l=364.0, t=724.0, r=440.0, b=768.0)px, Tag: 'TAG_F'
| Focused = 'false'
| Text = 'TEXT_F'
| Actions = [OnClick, GetTextLayoutResult]
| MergeDescendants = 'true'
|-Node #29 at (l=584.0, t=724.0, r=660.0, b=768.0)px, Tag: 'TAG_G'
| Focused = 'false'
| Text = 'TEXT_G'
| Actions = [OnClick, GetTextLayoutResult]
| MergeDescendants = 'true'
|-Node #33 at (l=804.0, t=724.0, r=880.0, b=768.0)px, Tag: 'TAG_H'
| Focused = 'false'
| Text = 'TEXT_H'
| Actions = [OnClick, GetTextLayoutResult]
| MergeDescendants = 'true'
|-Node #37 at (l=0.0, t=0.0, r=1024.0, b=768.0)px
Focused = 'false'
Text = 'TEXT_I'
VerticalScrollAxisRange = 'ScrollAxisRange(value=0.0, maxValue=0.0, reverseScrolling=false)'
Actions = [OnClick, GetTextLayoutResult, ScrollBy]
MergeDescendants = 'true'
|-Node #47 at (l=368.0, t=410.0, r=656.0, b=454.0)px, Tag: 'TAG_J'
| Focused = 'false'
| Text = 'TEXT_J'
| Actions = [OnClick, GetTextLayoutResult]
| MergeDescendants = 'true'
|-Node #51 at (l=368.0, t=462.0, r=656.0, b=506.0)px, Tag: 'TAG_K'
| Focused = 'false'
| Text = 'TEXT_K'
| Actions = [OnClick, GetTextLayoutResult]
| MergeDescendants = 'true'
|-Node #55 at (l=368.0, t=514.0, r=656.0, b=558.0)px, Tag: 'TAG_L'
Focused = 'false'
Text = 'TEXT_L'
Actions = [OnClick, GetTextLayoutResult]
MergeDescendants = 'true'
Failed to assert the following: (OnClick is defined)
Reason: Expected exactly '1' node but could not find any node that satisfies: (TestTag = 'SOME_TEST_TAG')
However, the unmerged tree contains '1' node that matches. Are you missing `useUnmergedNode = true` in your finder?
java.lang.AssertionError: Failed to assert the following: (OnClick is defined)
Reason: Expected exactly '1' node but could not find any node that satisfies: (TestTag = 'SOME_TEST_TAG')
However, the unmerged tree contains '1' node that matches. Are you missing `useUnmergedNode = true` in your finder?
I printed out every node except for the one with "SOME_TEST_TAG"czuckie
10/20/2022, 1:56 PMZach Klippenstein (he/him) [MOD]
10/20/2022, 3:40 PMCedric Lindigkeit
10/21/2022, 6:56 AMclass OurAwesomeTests {
@get:Rule
val rule: ComposeContentTestRule = createComposeRule()
private suspend fun initTestRule() {
rule.setContent {
ClickableText(
text = AnnotatedString("Hello World"),
modifier = Modifier.testTag("SOME_TEST_TAG"),
onClick = { }
)
}
rule.awaitIdle()
}
@Test
@OptIn(ExperimentalCoroutinesApi::class)
fun findMySpecialTag(): TestResult = runTest {
initTestRule()
rule.onRoot().printToLog("SOME_TEST_TAG")
rule.onNodeWithTag("SOME_TEST_TAG").performClick()
}
}
Throws
An operation is not implemented.
kotlin.NotImplementedError: An operation is not implemented.
at androidx.compose.ui.test.DesktopOutput_desktopKt.printToLog(DesktopOutput.desktop.kt:20)
at androidx.compose.ui.test.OutputKt.printToLog(Output.kt:69)
at androidx.compose.ui.test.OutputKt.printToLog$default(Output.kt:63)
at eu.lindigkeit.someApplication.ui.OurAwesomeTests$findMySpecialTag$1.invokeSuspend(OurAwesomeTests.kt:43)
Zach Klippenstein (he/him) [MOD]
10/21/2022, 5:08 PM