Android LiveData in androidTest returns null
问题 I'm running an androidTest instrumentation test and I have a method that returns LiveData from a DAO object using Room. I'm calling the method like so: val animal = roomDatabase.animalsDao().getAnimal(1) animal.observeForever(mMockObserver) assertNotNull(animal.value) I used Mockito to mock the observer: @Mock private lateinit var mMockObserver = Observer<Animal> This should return an instance of LiveData containing the Animal at id 1, but it's null. It's my understanding that in order for