Issue
Recently I upgraded my JUnit 4 runner from androidx.test.runner.AndroidJUnit4 to androidx.test.ext.junit.runners.AndroidJUnit4.
When I execute the test i get the following error: Test running failed:
Instrumentation run failed due to 'Process crashed.'
The LogCat shows this error:
java.lang.InstantiationException:
java.lang.Class<androidx.test.ext.junit.runners.AndroidJUnit4> has no zero argument constructor
All the imports in the test are correct and I'm not getting any error in the build.
My app gradle look like this:
defaultConfig {
testInstrumentationRunner 'androidx.test.ext.junit.runners.AndroidJUnit4'
}
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation "androidx.test.ext:junit:1.1.0"
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Solution
try
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
in place of
testInstrumentationRunner 'androidx.test.ext.junit.runners.AndroidJUnit4'
Answered By - iDroid
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.