Тесты не найдены при использовании пользовательского бегуна - PullRequest
0 голосов
/ 27 декабря 2018

Я использую библиотеки androidx.test (которые я недавно перенес) в свой проект и использую пользовательские AndroidJUnitRunner.До миграции все работало нормально, но теперь я получаю эту ошибку -

Started running tests Test running failed: Instrumentation run failed due to 'Process crashed.' Empty test suite.

Используемый мной пользовательский класс бегуна расширяется от androidx.test.runner.AndroidJUnitRunner

Вфайл моего приложения build.gradle У меня есть следующие настройки -

testInstrumentationRunner "com.example.CustomTestRunner"

с зависимостями -

androidTestImplementation "androidx.test.ext:junit:1.1.0" androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test:core:1.1.0' androidTestImplementation "androidx.test:rules:1.1.1"

Все мои тестовые классы имеют@RunWith(androidx.test.ext.junit.runners.AndroidJUnit4.class)

Я застрял в этом.Любая помощь будет оценена.Спасибо.

Ответы [ 2 ]

0 голосов
/ 28 февраля 2019

Одной из возможных причин является старый Test Orchestrator (orchestrator-1.1.1.apk) или Test Services (test-services-1.1.1.apk) приложений, созданных для компонентов библиотеки поддержки Android и все еще установленных на целевом устройстве.Откройте Настройки -> Все приложения , найдите их и удалите.При повторном запуске тестов из Android Studio будут установлены новые приложения, созданные для AndroidX, и ваша проблема может исчезнуть.

0 голосов
/ 22 февраля 2019

Я видел это во время тестирования с использованием Android 4.4. Когда я переключился на Android 6 (SDK 23), проблема исчезла.

Я использовал androidx.test.ext.junit.runners.AndroidJUnit4 для своих инструментальных тестов @RunWith (AndroidJunit4.class)

, но мой testInstrumentationRunner использует пакет:

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Смешивание двух разных пакетов кажется странным, ноэто работает.

мое приложение / build.gradle имеет:

android {
    defaultConfig {
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    testOptions { 
        execution 'ANDROIDX_TEST_ORCHESTRATOR'
        unitTests {
            includeAndroidResources = true
        }
    }

    useLibrary 'android.test.runner'
    useLibrary 'android.test.base'
    useLibrary 'android.test.mock'
}

dependencies {
    //--------------------------------------------------------------------------------
    // Test Dependencies

    // Required -- JUnit 4 framework for standard unit tests.
    testImplementation "junit:junit:$rootProject.ext.junitVersion"

    androidTestImplementation "junit:junit:$rootProject.ext.junitVersion"
    androidTestImplementation "org.hamcrest:hamcrest-library:$rootProject.ext.hamcrestVersion"

    // Mockito framework for NMEA-parser unit tests.
    testImplementation "org.mockito:mockito-core:$rootProject.ext.mockitoVersion"

    // Room testing
    androidTestImplementation "androidx.room:room-testing:$rootProject.ext.roomVersion"

    // Core library
    androidTestImplementation "androidx.test:core:$rootProject.ext.testCoreVersion"
    androidTestImplementation "androidx.arch.core:core-testing:$rootProject.ext.coreVersion"

    // AndroidJUnitRunner and JUnit Rules
    // deprecated
    androidTestImplementation "androidx.test:runner:$rootProject.ext.runnerVersion"
    androidTestImplementation "androidx.test:rules:$rootProject.ext.rulesVersion"

    // Assertions
    androidTestImplementation "androidx.test.ext:junit:$rootProject.ext.junitRunnerVersion"
    androidTestUtil "androidx.test:orchestrator:$rootProject.ext.orchestratorVersion"

//    androidTestImplementation "androidx.test.ext:truth:$rootProject.ext.xTruthVersion"
//    androidTestImplementation "com.google.truth:truth:$rootProject.ext.truthVersion"

    // Espresso dependencies
//    androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.ext.espressoVersion"
//    androidTestImplementation "androidx.test.espresso:espresso-contrib:$rootProject.ext.espressoVersion"
//    androidTestImplementation "androidx.test.espresso:espresso-intents:$rootProject.ext.espressoVersion"
//    androidTestImplementation "androidx.test.espresso:espresso-accessibility:$rootProject.ext.espressoVersion"
//    androidTestImplementation "androidx.test.espresso:espresso-web:$rootProject.ext.espressoVersion"
//    androidTestImplementation "androidx.test.espresso.idling:idling-concurrent:$rootProject.ext.espressoVersion"
//    androidTestImplementation "androidx.test.espresso:espresso-idling-resource:$rootProject.ext.espressoVersion"
}

configurations {
    all {
        resolutionStrategy {
            force "androidx.recyclerview:recyclerview:$rootProject.ext.recyclerviewVersion"
            force "org.checkerframework:checker-qual:$rootProject.ext.checkerQualVersion"
            force "org.checkerframework:checker-compat-qual:$rootProject.ext.checkerQualVersion"
            force "com.google.errorprone:error_prone_annotations:$rootProject.ext.errorProneAnnotationsVersion"
        }
    }
}

and I have these library versions:

        // Core Test library
        testCoreVersion = '1.1.0'
        coreVersion = '2.0.0-alpha1'

        // Automated Test Libraries
        // Instrumentation Test Runner
        junitRunnerVersion = '1.1.0'
        runnerVersion = '1.1.1'
        rulesVersion = '1.1.1'
        xTruthVersion = '1.0.0'
        truthVersion = '0.42'
        espressoVersion = '3.1.0'
        hamcrestVersion = '1.3'
        orchestratorVersion = '1.1.0'

        // JUnit library version
        junitVersion = '4.12'

        // Mockito version
        mockitoVersion = '2.21.0'

        // Force testing dependencies
        recyclerviewVersion = '1.0.0'
        checkerQualVersion = '2.5.3'
        errorProneAnnotationsVersion = '2.3.1'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...