Gradle中的并行任务未完成(connectedAndroidTest)

时间:2017-11-20 02:43:25

标签: android google-app-engine gradle google-cloud-platform google-cloud-endpoints

我在org.gradle.parallel=true开启gradle.properties。我正在运行后端Google云端模块,并且还运行了一个执行Espresso测试的connectedAndroidTest。测试成功,绿色任务正常(参见图片),但连接的测试任务实际上从未完成或打印线,并且不会继续执行队列中的下一个任务。

如果我自己运行任务,它就会结束并打印该行。

我的root build.gradle文件:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

// Task to set up GCE, runs paid flavor test and shuts down the server.
task configureTest {
    dependsOn 'startBackend', 'runInstrumentedTest', 'stopBackend'
    doLast {
        println 'Tests carried out and local server shut down'
    }
}

task startBackend {
    dependsOn ':backend:appengineRun'
}

// Run InstrumentedTest only in paid flavor as there is no interstitial ad.
task runInstrumentedTest {
    mustRunAfter 'startBackend'
    dependsOn ':app:connectedPaidDebugAndroidTest'
    doLast {
        println 'The test finished.'
    }
}

task stopBackend 
    mustRunAfter 'runInstrumentedTest'
    dependsOn ':backend:appengineStop'
}

Screenshot

1 个答案:

答案 0 :(得分:1)

要避免任何阻止,请尝试以守护进程模式启动后端,看看它是否可以帮助您正确完成测试。为此,请在后端的build.gradle文件中添加以下内容:

    task startBackend {
        project(":backend").afterEvaluate { backend ->
            backend.extensions.appengine.daemon = true
        }
        // ...
    }

请参阅以下帖子以获取更多信息: