Leave a rating/review
For now close all your files, close all your tabs and create a new test package for your integration tests. And create a new package for your integration tests by switching to the project view. Open the app package, source, select a new directory and name it androidTest.
And in here we are going to create the same package structure that we have in the other folders. So, new directory, java, and in here new package:
com.raywenderlich.android.wishlist
And in here we are going to be creating the integrtion tests for our app. The first one is going to be DetailViewModelTest.
There is also a shortcut that you can use to create the tst for a certain class. Open your main package -> java -> DetailViewModel. Let me delete this class.
If you want to create a test for a certain class simply press CMD + SHIFT + T, create new test, leave the default options, notice how the test keyword is already appended to the end of our class name. OK
In here select your androidTest package since we want to create an integration test. I’m going to delete this import, I’m also going to delete this internal keyword, add braces, and you will need to add a rule for your tests:
@get:Rule
var instantTaskExecutorRule = InstantTaskExecutorRule()
This is the same test rule that you use for mockito to make sure that when you are using live data and viewmodel it is all run synchronously in your tests.
Nice!