Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using createComposeTestRule() which does not exist.
Using createComposeUiRule() which is incorrect.
✗ Incorrect
The correct function to create a Compose test rule is createAndroidComposeRule().
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using launchContent() which is not a valid method.
Using showContent() which does not exist.
✗ Incorrect
The method to set the Compose UI content in tests is setContent.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Submit without quotes causes a compile error.
Using single quotes 'Submit' is invalid in Kotlin for strings.
✗ Incorrect
The text parameter must be a string literal with double quotes in Kotlin.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertExists() only checks existence, not visibility.
Using assertVisible() is not a valid Compose test method.
✗ Incorrect
Use onNodeWithContentDescription("Close") to find the node and assertIsDisplayed() to check visibility.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using LabelText which is not a valid matcher.
Not quoting the input string "user123".
✗ Incorrect
Use onNodeWithContentDescription("Username") to find the input, performTextInput("user123") to enter text, and onNodeWithText("user123") to verify.