Skip to content

Test UI

Ali Sadeghi edited this page Jan 6, 2026 · 7 revisions

Test UI Agent

Generates Compose UI tests.

Example Output

// feature/login/src/androidTest/kotlin/presentation/ui/LoginScreenTest.kt
@RunWith(AndroidJUnit4::class)
class LoginScreenTest {
    @get:Rule
    val composeTestRule = createComposeRule()

    @Test
    fun loginScreen_initialState_showsForm() {
        composeTestRule.setContent {
            XTheme {
                LoginScreen(
                    onLoginSuccess = {},
                    onBackClick = {}
                )
            }
        }

        composeTestRule.onNodeWithText("Email").assertIsDisplayed()
        composeTestRule.onNodeWithText("Password").assertIsDisplayed()
        composeTestRule.onNodeWithText("Login").assertIsDisplayed()
    }

    @Test
    fun loginScreen_enterCredentials_enablesButton() {
        composeTestRule.setContent {
            XTheme {
                LoginScreen(
                    onLoginSuccess = {},
                    onBackClick = {}
                )
            }
        }

        composeTestRule.onNodeWithText("Email").performTextInput("test@example.com")
        composeTestRule.onNodeWithText("Password").performTextInput("password123")

        composeTestRule.onNodeWithText("Login").assertIsEnabled()
    }

    @Test
    fun loginScreen_loadingState_showsIndicator() {
        // Test loading state
    }
}

Back to Agents

Clone this wiki locally