Exercise 7.01 – Adding tests to Flows in an Android app
For this exercise, you will be continuing the movie app you worked on in Exercise 6.01 – Handling Flow exception in an Android app. This application displays the movies that are currently playing in movie theatres. You will be adding tests for the Kotlin Flows in the project by following these steps:
- Open in Android Studio the movie app you worked on in Exercise 6.01 – Handling Flow exception in an Android app.
- Go to the
MovieViewModelTest
class. Run the test class, and thefetchMovies()
test function will fail. That is because we changed the implementation to use Flow in the previous chapter. - Remove the content of the
fetchMovies()
test function and replace it with the following content:@Test fun fetchMovies() { val dispatcher = StandardTestDispatcher() val movies = listOf(Movie(title = "Movie")) val expectedMovies...