I was trying to test the UI I built using jetpack compose in android and added these dependancies to set it up
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.1.0"
debugImplementation "androidx.compose.ui:ui-test-manifest:1.0.5"
for the testing I was just starting to write the following
class LoginActivityComposeTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
fun socialPluginsTest() {
composeTestRule.setContent {
SocialLogins()
}
}
}
The createComposeRule() which I am trying to import was not available. I've tried to manually import from import androidx.compose.ui.test.junit4.createComposeRule But when I try to run the tests after that there is an error showing
Unresolved reference: junit4
Here is the full build.gradle dependancies I am using
compose_version = '1.0.1' retrofit_version = '2.9.0'
implementation "androidx.core:core-ktx:1.7.0"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
implementation "androidx.activity:activity-compose:1.4.0"
implementation "androidx.navigation:navigation-compose:2.5.0-alpha01"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation "io.reactivex.rxjava2:rxkotlin:2.4.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0"
implementation 'com.google.android.gms:play-services-auth:20.1.0'
implementation "io.coil-kt:coil-compose:1.4.0"
testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.1.0"
debugImplementation "androidx.compose.ui:ui-test-manifest:1.0.5"
I placed the test file in the wrong folder. I put it in the test folder but it should be in the androidTest folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With