Writing tests for navigation
Now that we have created a new screen for our SampleLogin
project, we need to fix the broken test and add new tests for the UI package. If you can recall, in Chapter 3, Handling the UI State in Jetpack Compose and Using Hilt, we did unit tests and not UI tests. This means after adding all the ViewModel
instances, our UI tests are now broken. In this recipe, we will fix the failing tests and add a navigation test.
Getting ready
In this recipe, you do not need to create any new project; use the already-created project, SampleLogin
.
How to do it…
You can apply these concepts to test the bottom navigation bar we created. Hence, we will not be writing tests for the BottomNavigationBarSample
project. Open SampleLogin
and navigate to the androidTest
package. We will add tests here for the new RegisterScreen()
a Composable function, and also fix the broken tests:
- Let’s open the
LoginContentTest
class. Now, let’s move the...