小编Nic*_*ini的帖子

如何在启用并行模式的情况下运行Android robolectric测试

我在干净的Gradle和Maven缓存上以并行模式运行Robolectric测试时遇到麻烦。

这是build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.robolectrictest.robotest"
        minSdkVersion 21
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }

    testOptions.unitTests.all {
        testLogging {
            events "failed", "skipped"
            showStackTraces = true
            exceptionFormat = "full"
        }
        maxParallelForks = 8
        forkEvery = 20
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    testCompile 'org.robolectric:robolectric:3.0'
    androidTestCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)

在API 23上构建会显示相同的问题。如果我清除缓存(通过删除〜/ .gradle / caches /和〜/ .m2 /存储库)并运行

./gradlew clean test
Run Code Online (Sandbox Code Playgroud)

我遇到以下异常:

com.robolectrictest.robotest.ExampleUnitTest1 > addition_isCorrect1_1 FAILED
Unable to resolve artifact: …
Run Code Online (Sandbox Code Playgroud)

android maven robolectric android-gradle-plugin

5
推荐指数
0
解决办法
735
查看次数