Gradle Test Executor以非零退出代码完成

时间:2016-03-30 12:39:52

标签: android gradle android-gradle

使用Gradle 2.12和

org.gradle.daemon=false
org.gradle.configureondemand=true
org.gradle.parallel=false
gradle.properties中的

:app:processDevDebugJavaRes UP-TO-DATE
:app:processDevDebugUnitTestJavaRes
:app:compileDevDebugUnitTestSources
:app:mockableAndroidJar
:app:assembleDevDebugUnitTest
:app:testDevDebugUnitTest
objc[16261]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
:app:testDevDebugUnitTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:testDevDebugUnitTest'.
> Process 'Gradle Test Executor 1' finished with non-zero exit value 10

使用stacktrace

运行时
Caused by: org.gradle.process.internal.ExecException: Process 'Gradle Test Executor 1' finished with non-zero exit value 10
    at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:367)
    at org.gradle.process.internal.DefaultWorkerProcess.waitForStop(DefaultWorkerProcess.java:161)
    at org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor.stop(ForkingTestClassProcessor.java:89)
    at org.gradle.api.internal.tasks.testing.processors.RestartEveryNTestClassProcessor.endBatch(RestartEveryNTestClassProcessor.java:63)
    at org.gradle.api.internal.tasks.testing.processors.RestartEveryNTestClassProcessor.stop(RestartEveryNTestClassProcessor.java:57)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch.FailureHandlingDispatch.dispatch(FailureHandlingDispatch.java:29)
    at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)
    at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)
    at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)

使用--debug运行时:(我已经编辑了一些测试名称)

14:41:18.772 [DEBUG] [TestEventLogger] <REDACTED>ActionBarTest STARTED
14:41:18.907 [DEBUG] [TestEventLogger]
14:41:18.907 [DEBUG] [TestEventLogger] <REDACTED>ActionBarTest > shouldRegisterTimeChangeBroadcastReceiverOnStart STARTED
14:41:23.158 [DEBUG] [TestEventLogger]
14:41:23.158 [DEBUG] [TestEventLogger] <REDACTED>ActionBarTest > shouldRegisterTimeChangeBroadcastReceiverOnStart PASSED
14:41:23.159 [DEBUG] [TestEventLogger]
14:41:23.159 [DEBUG] [TestEventLogger] <REDACTED>ActionBarTest > shouldShoBlahdAsTitle STARTED
14:41:23.666 [DEBUG] [org.gradle.messaging.remote.internal.inet.SocketConnection] Discarding EOFException: java.io.EOFException
14:41:23.667 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
14:41:23.667 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'Gradle Test Executor 1' finished with exit value 10 (state: FAILED)
14:41:23.669 [DEBUG] [TestEventLogger]
14:41:23.669 [DEBUG] [TestEventLogger] Gradle Test Run :app:testDevDebugUnitTest PASSED
14:41:23.669 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':app:testDevDebugUnitTest'
14:41:23.669 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :app:testDevDebugUnitTest FAILED
14:41:23.670 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :app:testDevDebugUnitTest (Thread[Daemon worker Thread 4,5,main]) completed. Took 5.807 secs.
14:41:23.670 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker Thread 4,5,main]] finished, busy: 6.945 secs, idle: 0.007 secs
14:41:23.670 [ERROR] [org.gradle.BuildExceptionReporter]
14:41:23.672 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
14:41:23.672 [ERROR] [org.gradle.BuildExceptionReporter]
14:41:23.672 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
14:41:23.672 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:testDevDebugUnitTest'.
14:41:23.672 [ERROR] [org.gradle.BuildExceptionReporter] > Process 'Gradle Test Executor 1' finished with non-zero exit value 10

导致exec异常的原因是什么? ./gradlew test经常因此错误而失败。

1 个答案:

答案 0 :(得分:0)

我们正在使用ACRA,这在测试运行时就开始了。该库有一个System.exit(1)并且也杀死了测试套件。

此错误是ACRA捕获的其他错误(我的情况下是NPE)的症状,ACRA试图记录NPE并最终停止测试执行者。

一般情况下,如果您在测试期间面对其他错误处理框架,请查看。