0% found this document useful (0 votes)
44 views

Compose Testing Cheatsheet

How to test in Kotlin Compose Android Platform

Uploaded by

Gurung Siz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Compose Testing Cheatsheet

How to test in Kotlin Compose Android Platform

Uploaded by

Gurung Siz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

v1.0.

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
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

isRoot onSibling assertLeftPositionInRootIsEqualTo

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

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