Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

v1.1.

Testing cheat sheet


Finders Assertions
onNode(matcher) onAllNodes(matcher) assert(matcher)

onNodeWithContentDescription onAllNodesWithContentDescription assertExists

onNodeWithTag onAllNodesWithTag assertDoesNotExist

onNodeWithText onAllNodesWithText assertContentDescriptionContains

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

ComposeTestRule AndroidComposeTestRule Debug


@get:Rule
@get:Rule

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

You might also like