AndroidJUnit4.class is deprecated: How to use androidx.test.ext.junit.runners.AndroidJUnit4?

前端 未结 8 1647
傲寒
傲寒 2020-12-04 08:04

For my instrumentation tests I was using

@RunWith(AndroidJUnit4.class)

from

import androidx.test.runner.AndroidJUnit4;
         


        
8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 08:42

    According to the documentation for AndroidJUnit4,

    1. The gradle file should contain the following line:

    androidTestImplementation 'androidx.test.ext:junit:1.1.1'

    1. Change test class to AndroidJUnit4ClassRunner from AndroidJUnit4

    If it still doesn't work, make sure that you clean and/or rebuild your project. Also you can check the current version directly in Google's maven repository

提交回复
热议问题