'Instrumented Test not running in Android Tests Passed 0 Passed
I have been trying to run a test case , present in androidTest Package. But as i execute the test, Emulator launches and I get tests passed : 0 Passed.
and getting this Error in logcat
E/AndroidJUnitRunner: An unhandled exception was thrown by the app.
E/InstrumentationResultPrinter: Failed to mark test No Tests as finished after process crash
here is my code.
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import kotlin.test.assertEquals
@RunWith(AndroidJUnit4::class)
class MyAndroidTest {
@Test
fun test_simple() {
assertEquals(2, 1+1)
}
}
I have added all required dependencies.
testImplementation 'junit:junit:4.12'
androidTestImplementation 'junit:junit:4.12'
testImplementation "androidx.test.ext:junit-ktx:1.1.3"
androidTestImplementation "androidx.test.ext:junit-ktx:1.1.3"
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
testImplementation "org.robolectric:robolectric:4.6"
testImplementation "com.google.truth:truth:1.1.3"
androidTestImplementation "com.google.truth:truth:1.1.3"
testImplementation 'org.mockito:mockito-core:2.24.5'
// required if you want to use Mockito for Android tests
androidTestImplementation 'org.mockito:mockito-android:2.24.5'
When I run the same test case in test package, it runs successfully. One thing is, I created The androidTest package by myself. It was somehow deleted earlier..
I get this after I run the test case,
plz help.
Solution 1:[1]
Add testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
in defaultConfig block inside gradle module file
Is missing in that project and it's necessary.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | NullPointerException |