Как я могу написать SmallTests в android studio, ошибка @SmallTest не может быть решена меня разочаровывает - PullRequest
1 голос
/ 07 февраля 2020

Я учусь писать модульные тесты для Android, исследовал и теперь имею представление о том, как их написать. Я узнал, что мне нужно использовать аннотацию @SmallTest из класса android.test.suitebuilder.annotation.SmallTest;, но это устарело. Тем не менее, я получаю сообщение об ошибке, что @SmallTest не может быть решена. Я ищу лучший способ сделать это или какой импорт / зависимости я должен использовать для достижения своей цели. Ниже приведены мои зависимости от Gradle.

compileSdkVersion 28
buildToolsVersion "29.0.0"
defaultConfig {
    applicationId "com.techweezy.roomexample"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    // Required -- JUnit 4 framework
    testImplementation 'junit:junit:4.12'
    // Optional -- Robolectric environment
    testImplementation 'androidx.test:core:1.0.0'
    // Optional -- Mockito framework
    testImplementation 'org.mockito:mockito-core:1.10.19'
    implementation 'com.android.support:support-annotations:28.0.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'

    androidTestImplementation 'com.android.support.test:rules:0.4'

    def room_version = "2.2.3"

    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    // For Kotlin use kapt instead of annotationProcessor

    // optional - RxJava support for Room
    implementation "androidx.room:room-rxjava2:$room_version"

    // optional - Guava support for Room, including Optional and ListenableFuture
    implementation "androidx.room:room-guava:$room_version"

    // Test helpers
    testImplementation "androidx.room:room-testing:$room_version"
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'org.hamcrest:hamcrest-library:1.3'
} 
...