Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
I had upgraded to androidx libraries and started getting this error.
To fix it, in build.gradle I changed the line:
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
to
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
FYI I ran into this and had to add
<uses-library android:name="android.test.runner"/>
within my <application/>
tag
In my case, I was trying to run the tests on Jelly Bean emulator. Android instrumentation does not seem to support Jelly Bean. I could run the tests on lollipop.
You may also not able to run android tests through release build type. Ensure that debug build type is active.