ARTICLE AD BOX
Asked today
Viewed 37 times
I'm trying to run instrumentation tests but
Classes are not getting resolved, getting Cannot find declaration to go to Run button icon is not appearing for @Test functions so not able to run tests androidTest folder is not getting green background color to resolve as test sources rootI tried "Mark Directory as-> Test sources root" but no luck I tried Invalidate caches and restart, and tried Android Studio Ladybug & Meerkat versions too.
Gradle:
testImplementation 'junit:junit:4.13.2' testImplementation 'io.mockk:mockk:1.13.8' testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3' testImplementation 'com.squareup.okhttp3:okhttp:4.12.0' testImplementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' androidTestImplementation 'androidx.test.ext:junit:1.2.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation platform('androidx.compose:compose-bom:2024.11.00') androidTestImplementation 'androidx.compose.ui:ui-test-junit4' debugImplementation 'androidx.compose.ui:ui-tooling' debugImplementation 'androidx.compose.ui:ui-test-manifest'and testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" also added
Any tips/solutions will be helpful?

4,1317 gold badges37 silver badges63 bronze badges
This happens when instrumentation tests aren’t set up correctly.
Make sure the test class is inside app/src/androidTest/java (not src/test). Instrumentation tests won’t work from the test folder.
Also, use androidTestImplementation for JUnit/AndroidX test deps (not testImplementation), and set
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" in defaultConfig.
After fixing this, sync Gradle + Clean/Rebuild. The androidTest folder should turn green and the ▶ Run icon will appear.
Explore related questions
See similar questions with these tags.
