From 3f8b0d70367cbbcefe9640965e528d6d9b5b5064 Mon Sep 17 00:00:00 2001 From: sridhar-sp Date: Sat, 4 Jan 2025 00:06:29 +0530 Subject: [PATCH] Update readme - WIP --- README.md | 34 +++++++++++++++++++ .../presentation/main/MainScreenTest.kt | 1 - 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f8ab035..88673eb 100644 --- a/README.md +++ b/README.md @@ -531,7 +531,41 @@ Explain about system under test ### Test ```kotlin +@HiltAndroidTest +class MainScreenTest { + + @get:Rule(order = 0) + val hiltAndroidRule = HiltAndroidRule(this) + + /** + * Need a activity that annotated with @AndroidEntryPoint. and it has to be registered in manifest. + * Add comment why we used createAndroidComposeRule instead of composeTestRule + */ + @get:Rule(order = 1) + val androidComposeRule = createAndroidComposeRule() + + @Test + fun shouldSuccessfullyLaunchProfileScreenWithEmailPostLogin() { + + with(androidComposeRule) { + setContent { MainScreen() } + + onNodeWithTag("emailInput").performTextInput("abc@gmail.com") + onNodeWithTag("passwordInput").performTextInput("12345") + onNodeWithTag("loginButton").performClick() + + waitUntil(2500L) { + onAllNodesWithTag("welcomeMessageText").fetchSemanticsNodes().isNotEmpty() + } + onNodeWithTag("welcomeMessageText").assertTextEquals("Email as explicit argument abc@gmail.com") + onNodeWithTag("welcomeMessageText2") + .assertTextEquals("Email from saved state handle abc@gmail.com") + + waitForIdle() + } + } +} ``` ### Dependencies diff --git a/app/src/androidTest/java/com/gandiva/android/sample/presentation/main/MainScreenTest.kt b/app/src/androidTest/java/com/gandiva/android/sample/presentation/main/MainScreenTest.kt index 775a683..63081ed 100644 --- a/app/src/androidTest/java/com/gandiva/android/sample/presentation/main/MainScreenTest.kt +++ b/app/src/androidTest/java/com/gandiva/android/sample/presentation/main/MainScreenTest.kt @@ -14,7 +14,6 @@ import org.junit.Before import org.junit.Rule import org.junit.Test - @HiltAndroidTest //@RunWith(AndroidJUnit4::class) class MainScreenTest {