I want to write some UI tests and to have ability to run it using robolectric, I placed this test in shared test folder (shared folder was created using this guide), but it just not compile. Nor AndroidJUnit4::class annotation nor random methods in Espresso. In the same time UI test that placed in androidTest folder working as expected!
I have tried to build/rebuild/clean project before writing this question.
My build.gradle file
defaultConfig {
applicationId "com.test.codelabtodoclone"
minSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
android {
sourceSets {
String sharedTestDir = 'src/sharedTest/java'
androidTest {
java.srcDir sharedTestDir
}
test {
java.srcDir sharedTestDir
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation "androidx.annotation:annotation:1.1.0"
// Unit-tests
testImplementation 'junit:junit:4.12'
testImplementation "androidx.arch.core:core-testing:2.1.0"
testImplementation 'androidx.test:core:1.2.0'
testImplementation 'androidx.test:runner:1.2.0'
testImplementation "androidx.test:core-ktx:1.2.1-alpha02"
testImplementation "androidx.test.ext:junit-ktx:1.1.2-alpha02"
testImplementation "androidx.test:rules:1.3.0-alpha02"
testImplementation "androidx.test.espresso:espresso-core:3.3.0-alpha02"
testImplementation "androidx.test.espresso:espresso-contrib:3.3.0-alpha02"
testImplementation 'org.robolectric:robolectric:4.3.1'
// Instrumented tests
androidTestImplementation "junit:junit:4.12"
androidTestImplementation "androidx.arch.core:core-testing:2.1.0"
androidTestImplementation "androidx.test:core:1.2.0"
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation "androidx.test:core-ktx:1.2.1-alpha02"
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.1'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation "androidx.annotation:annotation:1.1.0"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation "androidx.test.espresso:espresso-contrib:3.2.0"
// ...
}
Aucun commentaire:
Enregistrer un commentaire