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
hasSetTextAction hasAnyDescendant
hasStateDescription hasAnyAncestor
hasTestTag
Collections
hasText[Exactly] assertAll
is[Not]Dialog assertAny
is[Not]Enabled Selectors assertCountEquals(Int)
is[Not]Focused filter(matcher)
is[Not]Selected filterToOne(matcher)
isHeading
onAncestors
isOff
onChild
isOn BOUNDS
onChildAt assertWidthIsEqualTo
isPopup onChildren
isSelectable
assertHeightIsEqualTo
onFirst assertWidthIsAtLeast
isToggleable
onLast
isFocusable
assertHeightIsAtLeast
onParent assertTopPositionInRootIsEqualTo
onSiblings getAlignmentLinePosition(BaseLine)
getUnclippedBoundsInRoot
Actions
performClick GESTURES Partial gestures
performGesture
click
down
performScrollTo
doubleClick
moveTo
performSemanticsAction
longClick
movePointerTo
performKeyPress
pinch
moveBy
performImeAction
swipe
movePointerBy
performTextClearance
swipe[Down|Left|Right|Up]
move
performTextInput
swipeWithVelocity up
performTextReplacement
cancel
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