本文参考自 Unit-testing LiveData and other common observability problems
参考 Google 代码官方测试代码 here
单元测试时,LiveData.value 返回 null
@Test
@Throws(Exception::class)
fun testLiveDataFail() = runBlocking {
meditationDao.insert(MeditationTrip())
val trips = meditationDao.getAllTrips()
assertEquals