Migrating Junit4 tests to androidx: What causes 'delegate runner could not be loaded'?

后端 未结 19 1806
长情又很酷
长情又很酷 2020-12-05 06:35

I am migrating my app to androidx, I can\'t seem to get my unit tests working. I took example from Google\'s AndroidJunitRunnerSample, which has been updated to use the new

19条回答
  •  独厮守ぢ
    2020-12-05 06:40

    You also get the error message if you use a test rule in Kotlin and write it Java style

    @Rule
    var mainActivityActivityTestRule = ActivityTestRule(MainActivity::class.java)
    

    You have to change @Rule to @get:Rule

    @get:Rule
    var mainActivityActivityTestRule = ActivityTestRule(MainActivity::class.java) 
    

提交回复
热议问题