简体   繁体   中英

Instrumented test

I am trying to run a test:

@HiltAndroidTest
class ActionDaoTest {

@get : Rule
var hiltRule = HiltAndroidRule(this)

@get : Rule
var instantTaskExecutorRule = InstantTaskExecutorRule()

@Inject
@Named("test_db")
lateinit var database: MyDatabase

private lateinit var actionDao: ActionDao

@Before
fun setup() {
    hiltRule.inject()
    actionDao = database.actionDao()
}

@After
fun teardown(){
    database.close()
}

@Test
fun insert_assetTrue() = runTest{
    val action = ActionEntity("name","description", LocalDate.now())
    actionDao.insert(action)
    val actionList= actionDao.selectAll().first()
    assertThat(actionList).contains(action)
}

}

I get an error:

java.lang.NoSuchMethodError: No virtual method find(Lkotlin/jvm/functions/Function1;)Lkotlinx/coroutines/internal/ThreadSafeHeapNode; in class Lkotlinx/coroutines/internal/ThreadSafeHeap; or its super classes

I downgraded
'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4' to 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0' and now it works...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM