Cannot resolve symbol 'AndroidJUnit4'

前端 未结 19 2259
别跟我提以往
别跟我提以往 2020-12-02 08:48

Obviously I need the correct import statment to solve this problem. According to the docs for AndroidJUnit4, this should be

import android.support.test.runn         


        
19条回答
  •  青春惊慌失措
    2020-12-02 09:37

    Notice that this the OP is now in 2019 , 4 years old so If you are using Android X then AndroidJUnit4.class is deprecated , you have an error there and one more with this androidx.test.ext.junit.runners.AndroidJUnit4. I suggest to read this links to solve the problem .

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

    Migrating Junit4 tests to androidx: What causes 'delegate runner could not be loaded'? For me Android Studio suggested to replace

    @RunWith(AndroidJUnit4.class)
    

    which was deprecated with

    @RunWith(AndroidJUnit4ClassRunner.class)
    

    and this

    androidx.test.ext.junit.runners.AndroidJUnit4
    

    with this

    import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
    

    After that the error is gone but I don't know if the future test while run ok ?!

提交回复
热议问题