Professional Documents
Culture Documents
Compose Testing Cheatsheet
Compose Testing Cheatsheet
onRoot assertContentDescriptionEquals
assertIs[Not]Displayed
assertIs[Not]Enabled
assertIs[Not]Selected
OPTIONS: useUnmergedTree: Boolean assertIs[Not]Focused
assertIsOn
assertIsOff
assertIsToggleable
Matchers assertIsSelectable
assertTextEquals
assertTextContains
assertValueEquals
has[No]ClickAction Hierarchical assertRangeInfoEquals
hasContentDescription[Exactly] assertHas[No]ClickAction
hasImeAction hasParent
hasProgressBarRangeInfo hasAnyChild
has[No]ScrollAction
hasAnySibling
hasScrollTo[Index|Key|Node]Action hasAnyDescendant
hasSetTextAction hasAnyAncestor
hasStateDescription
Collections
hasTestTag assertAll
hasText[Exactly] assertAny
is[Not]Dialog Selectors assertCountEquals(Int)
is[Not]Enabled filter(matcher)
is[Not]Focused filterToOne(matcher)
is[Not]Selected onAncestors
isHeading
onChild
isOff
BOUNDS
onChildAt assert[Width|Height]IsEqualTo
isOn onChildren
isPopup assertIsEqualTo
onFirst assert[Width|Height]IsAtLeast
isSelectable
onLast
isToggleable
assertTouch[Width|Height]IsEqualTo
onParent assertTopPositionInRootIsEqualTo
isFocusable
onSibling
isRoot assertLeftPositionInRootIsEqualTo
onSiblings getAlignmentLinePosition(BaseLine)
getUnclippedBoundsInRoot
Actions
performClick TOUCH INPUT TOUCH INPUT PARTIAL
performTouchInput
click
down
performMultiModalInput
doubleClick
moveTo
performScrollTo
longClick
movePointerTo
performSemanticsAction
pinch
moveBy
performKeyPress
swipe
movePointerBy
performImeAction
swipe[Down|Left|Right|Up]
move
performTextClearance
swipeWithVelocity up
performTextInput
cancel
performTextReplacement
val testRule =
val testRule =
onNode(...).*
createComposeRule() createAndroidComposeRule<Activity>()
setContent { }
ComposeTestRule.* + printToString()
density
printToLog()
activity
runOnIdle { }
captureToImage()
activityRule
runOnUiThread { }
waitForIdle()
waitUntil { }
awaitIdle()
[un]registerIdlingResource()
mainClock.autoAdvance
mainClock.currentTime
mainClock.advanceTimeBy()
mainClock.advanceTimeByFrame()
mainClock.advanceTimeUntil { }
goo.gle/compose-testing