Skip to content

Instantly share code, notes, and snippets.

@ngallazzi
Created December 29, 2023 14:37
Show Gist options
  • Save ngallazzi/758ed053020c97056f10ea2959dcb573 to your computer and use it in GitHub Desktop.
Save ngallazzi/758ed053020c97056f10ea2959dcb573 to your computer and use it in GitHub Desktop.
compose tests asserts
class MyLayoutTest {
@get:Rule
val composeTestRule = createAndroidComposeRule<ComponentActivity>()
@Test
fun testGreetingButtonExists() {
// Start the app
composeTestRule.setContent {
MyLayout()
}
// Asserts that a node with content description "Greeting Button" exists
composeTestRule.onNodeWithContentDescription(
"Greeting Button"
).assertExists()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment