Writing integration tests
In this section, we will look at the next step in the testing pyramid: integration tests. We will explore Robolectric to write more complex tests, and later on, we will learn how we can integrate ComposeTestRule
with Robolectric to test how we display UI elements.
Let’s assume your project is covered by unit tests, where a lot of your logic is held. You now must add these tested classes to an activity or a fragment and require them to update your UI. How can you be certain that these classes will work well with each other? The answer to that question is integration testing.
The idea behind this type of testing is to ensure that different components within your application integrate well with each other. Some examples include the following:
- Your networking components work well
- The storage components can store and retrieve the data correctly
- The UI components load and display the appropriate data
- The transition between...