Эспрессо не работает в общей тестовой папке - PullRequest
0 голосов
/ 25 октября 2019

Я хочу написать несколько тестов пользовательского интерфейса и иметь возможность запускать его с помощью robolectric. Я поместил этот тест в общую папку тестов (общая папка была создана с использованием этого руководства ), но он просто не компилируется. Ни AndroidJUnit4 :: класс аннотации, ни случайные методы в эспрессо. В то же время тест пользовательского интерфейса, помещенный в папку androidTest, работает должным образом!

Я пытался собрать / перестроить / очистить проект, прежде чем писать этот вопрос.

Мой файл build.gradle

    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"
    // ...
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...