简体   繁体   English

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

[英]Why does Gradle say "There were failing tests" when the test report shows no test failures?

I have had a similar problem before, but last time there were at least some test classes that failed to initialize or something like that.我以前也遇到过类似的问题,但上次至少有一些测试类无法初始化或类似的问题。 This time, Gradle says这一次,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/...

But the CI server, TeamCity, shows no test failures for this build.但是 CI 服务器 TeamCity 没有显示此构建的测试失败。 And even the JUnit report, when I re-run the failing Gradle task on my local machine to see that report, shows no test failures or errors!甚至 JUnit 报告,当我在本地机器上重新运行失败的 Gradle 任务以查看该报告时,也没有显示测试失败或错误! There is also nothing logged at ERROR level from the tests, and nothing logged at WARN level that I wouldn't expect to see, either.测试中也没有在 ERROR 级别记录任何内容,也没有在 WARN 级别记录任何我不希望看到的内容。

What could be the problem?可能是什么问题呢? How can I debug this?我该如何调试?

Passing --debug as a command-line argument to gradle :foo-bar:liveTest showed that it was:--debug作为命令行参数传递给gradle :foo-bar:liveTest表明它是:

10:52:10.894 [DEBUG] [TestEventLogger]         Caused by:
10:52:10.894 [DEBUG] [TestEventLogger]         java.lang.IncompatibleClassChangeError: 

referring to a class in the project - not in the dependencies - which would usually indicate that a class that should have been recompiled by Gradle had not, in fact, been recompiled.指的是项目中的一个类——而不是依赖项中的类——这通常表示应该由 Gradle 重新编译的类实际上没有被重新编译。 However, a Gradle clean did not fix the problem.然而,Gradle clean 并没有解决这个问题。

The problem turned out to be equivalent to this , although no Spring Boot was involved.尽管没有涉及 Spring Boot,但结果证明问题与this相同。

Running out of heap space is another common cause of this.耗尽堆空间是造成这种情况的另一个常见原因。 If you start poking around in the test output, you may find a file named build/reports/tests/test/classes/Gradle#20Test#20Executor#201.html (number at the end will vary) which finally reveals the issue:如果您开始查看测试输出,您可能会发现一个名为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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM