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
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 ?!