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

  • A+
Category:Languages

For my instrumentation tests I was using

@RunWith(AndroidJUnit4.class) 

from

import androidx.test.runner.AndroidJUnit4; 

in order to establish my test cases. Now this line gets marked as deprecated with the hint to use AndroidJUnit4 from

import androidx.test.ext.junit.runners.AndroidJUnit4 

However if I try to import AndroidJUnit4 from the named package I get the error, that ext can not be resolved.

Do you have an idea, what package should be included in gradle to resolve this issue?

 


I added the following line to my gradle file:

androidTestImplementation 'androidx.test.ext:junit:1.0.0-beta02' 

Now everything is working again now.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: