0
0
Android Kotlinmobile~10 mins

Compose UI testing in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Compose test rule.

Android Kotlin
val composeTestRule = create[1]Rule()
Drag options to blanks, or click blank then click option'
AComposeTest
BAndroidCompose
CComposeUi
DComposeActivity
Attempts:
3 left
💡 Hint
Common Mistakes
Using createComposeTestRule() which does not exist.
Using createComposeUiRule() which is incorrect.
2fill in blank
medium

Complete the code to set the content for Compose UI testing.

Android Kotlin
composeTestRule.[1] {
  Text("Hello Compose")
}
Drag options to blanks, or click blank then click option'
AstartContent
BlaunchContent
CsetContent
DshowContent
Attempts:
3 left
💡 Hint
Common Mistakes
Using launchContent() which is not a valid method.
Using showContent() which does not exist.
3fill in blank
hard

Fix the error in the code to find a node with text "Submit".

Android Kotlin
composeTestRule.onNodeWithText([1]).performClick()
Drag options to blanks, or click blank then click option'
A'Submit'
BSubmit
Csubmit
D"Submit"
Attempts:
3 left
💡 Hint
Common Mistakes
Using Submit without quotes causes a compile error.
Using single quotes 'Submit' is invalid in Kotlin for strings.
4fill in blank
hard

Fill both blanks to check if a node with content description "Close" is displayed.

Android Kotlin
composeTestRule.onNodeWith[1]("Close").[2]()
Drag options to blanks, or click blank then click option'
AContentDescription
BassertExists
CassertIsDisplayed
DassertVisible
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertExists() only checks existence, not visibility.
Using assertVisible() is not a valid Compose test method.
5fill in blank
hard

Fill all three blanks to perform a text input and verify it in Compose test.

Android Kotlin
composeTestRule.onNodeWith[1]("Username").performTextInput([2])
composeTestRule.onNodeWithText([3]).assertExists()
Drag options to blanks, or click blank then click option'
ALabelText
B"user123"
DContentDescription
Attempts:
3 left
💡 Hint
Common Mistakes
Using LabelText which is not a valid matcher.
Not quoting the input string "user123".