Answer the question
In order to leave comments, you need to log in
How to test LiveData?
LiveData always returns an empty sheet
@Test
fun insertHuman(){
val human =Human(first_name = "Test",last_name = "Test",age = "11",job = "Test")
db.takeDao().insertHuman(human)
var list:List<Human> = ArrayList<Human>()
db.takeDao().getPeople().observeForever{
list=it
}
runBlocking { delay(2000L) }
assertEquals(1,list.size)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question