Gradle测试执行器完成,退出代码为非零

pkln4tw6  于 2023-04-12  发布在  其他
关注(0)|答案(1)|浏览(185)

使用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经常失败并出现此错误。

j8yoct9x

j8yoct9x1#

一般来说,如果你遇到这个问题:寻找
1.退出代码。这个退出代码将在我们的源代码中,或者
1.其他第三方库/错误处理框架在运行测试套件时以某种方式被调用。
我们正在使用一个库来记录错误:ACRA和这个库,在运行测试套件时被调用,并导致整个VM退出。

System.exit(1)

whichkilledthe gradle/jvm process that runs test suite.
JVM退出又是由另一个错误引起的,一个NPE,它被ACRA(一个错误处理库)捕获,它试图记录NPE,并最终到达停止测试执行器VM的System.exit()代码。

相关问题