Learning the basics of testing your Compose UI
UI tests allow us to evaluate the behavior of our Compose code against what is expected to be correct. This way, we can catch bugs early in our UI development process.
To test our UI, we must first decide what we are aiming to evaluate. To keep it simple, in this section, we will unit-test our UI in an isolated environment. In other words, we want to test the following:
- That our composable screens consume the received state as expected. We want to make sure that the UI correctly represents the different state values that it can receive.
- For our composable screens, that user-generated events are correctly forwarded to the caller of the composable.
To keep our tests simple, we will define these tests as unit tests and try to isolate screen composables from their ViewModel
or from other screen composables; otherwise, our test will become an integration or an end-to-end test.
In other words, we will test separately...