Testing your local database
So far, we have ensured that we write tests whenever necessary for our projects. We will now need to go ahead and write tests for our RoomExample
project, since this is crucial, and you might be required to do so in a real-world scenario. Hence, in this recipe, we will look at a step-by-step guide on writing CRUD tests for our database.
Getting ready
You will need to open the RoomExample
project to get started with this recipe.
How to do it…
Let’s go ahead and first add all the needed Room testing dependencies, and then start writing our tests. For the Hilt test setup, refer to the Technical requirements section, where you can find all the required code:
- You will need to add the following to your
build.gradle
:androidTestImplementation "com.google.truth:truth:1.1.3"
androidTestImplementation "android.arch.core:core-testing:1.1.1"
- After you have added the required dependencies inside the Android test...