Skip to content

Commit

Permalink
Update readme - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sridhar-sp committed Jan 3, 2025
1 parent 9537a23 commit 3f8b0d7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<DummyTestActivity>()

@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test


@HiltAndroidTest
//@RunWith(AndroidJUnit4::class)
class MainScreenTest {
Expand Down

0 comments on commit 3f8b0d7

Please sign in to comment.