Created
July 16, 2025 15:00
-
-
Save Sprajapati123/7b5706842db71d7e3b30aa2d74f26ccb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.ai36 | |
import androidx.compose.ui.test.junit4.createAndroidComposeRule | |
import androidx.compose.ui.test.onNodeWithTag | |
import androidx.compose.ui.test.performClick | |
import androidx.compose.ui.test.performTextInput | |
import androidx.test.ext.junit.runners.AndroidJUnit4 | |
import com.example.ai36.view.LoginActivity | |
import org.junit.Rule | |
import org.junit.Test | |
import org.junit.runner.RunWith | |
@RunWith(AndroidJUnit4::class) | |
class LoginActivityTest { | |
@get:Rule | |
val composeRule = createAndroidComposeRule<LoginActivity>() | |
@Test | |
fun testSuccessfulLogin_navigatesToDashboard() { | |
// Enter email | |
composeRule.onNodeWithTag("email") | |
.performTextInput("[email protected]") | |
// Enter password | |
composeRule.onNodeWithTag("password") | |
.performTextInput("password") | |
// Click Login | |
composeRule.onNodeWithTag("button") | |
.performClick() | |
// You can now verify if DashboardActivity is launched. | |
// Basic workaround (check for no errors): | |
composeRule.waitForIdle() | |
} | |
@Test | |
fun testEmptyEmail_ShowsNoNavigation() { | |
composeRule.onNodeWithTag("button") | |
.performClick() | |
// Expect no crash or stay on same screen | |
composeRule.waitForIdle() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment