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

Viewed 4902

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

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. 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! 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.

What could be the problem? How can I debug this?

2 Answers

Passing --debug as a command-line argument to gradle :foo-bar:liveTest showed that it was:

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. However, a Gradle clean did not fix the problem.

The problem turned out to be equivalent to this, although no Spring Boot was involved.

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:

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
Related