当测试报告未显示测试失败时,为什么Gradle会说“测试失败”?

时间:2020-09-19 08:35:11

标签: java gradle junit

我以前也遇到过类似的问题,但是上一次至少有一些测试类未能初始化或类似的问题。这次,Gradle说

Task :foo-bar:liveTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':foo-bar:liveTest'.
> There were failing tests. See the report at: file:///C:/Users/...

但是CI服务器TeamCity没有显示此版本的测试失败。甚至当我在本地计算机上重新运行失败的Gradle任务以查看该报告时,甚至JUnit报告也没有显示测试失败或错误!测试也没有在ERROR级别记录任何内容,也没有在WARN级别记录的内容,我也不会看到。

可能是什么问题?我该如何调试?

2 个答案:

答案 0 :(得分:0)

row1作为命令行参数传递给--debug表示它是:

gradle :foo-bar:liveTest

在项目中指的是一个类,而不是在依赖项中,这通常表示,这表明应该由Gradle重新编译的类实际上并未被重新编译。但是,Gradle清理不能解决问题。

尽管没有涉及Spring Boot,但该问题等效于this

答案 1 :(得分:0)

耗尽堆空间是另一个常见原因。如果您开始查看测试输出,您可能会发现一个名为 build/reports/tests/test/classes/Gradle#20Test#20Executor#201.html(末尾的数字会有所不同)的文件,它最终揭示了问题:

org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not complete execution for Gradle Test Executor 1.
        at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:63)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
        at com.sun.proxy.$Proxy2.stop(Unknown Source)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:133)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.OutOfMemoryError: Java heap space