TestKit: How to turn off daemon?


(Simon Herter) #1

On Travis my tests repeatedly fail because of org.gradle.launcher.daemon.client.DaemonDisappearedExceptions.
I tried using GradleRunner.withArguments('--no-daemon'), but that’s not allowed. How can I prevent TestKit from using daemon mode?

Example build: https://travis-ci.org/sherter/google-java-format-gradle-plugin/jobs/134162967
(It’s strange that only the oraclejdk8 build always fails…)
Related: Travis CI: org.gradle.launcher.daemon.client.DaemonDisappearedException: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)


(Mark Vieira) #2

You can use withDebug(true), which will cause TestKit to execute in “embedded” mode, executing in-process rather than using a daemon.


(Simon Herter) #3

Thanks for the tip.
There is one problem though: When I turn debug mode on, I can’t access GradleRunner.build().output anymore (throws org.gradle.testkit.runner.UnsupportedFeatureException). Is this supposed to be like that? Then this workaround doesn’t help me very much…


(Benjamin Muschko) #4

You will need to use Gradle version >= 2.9 for testing your code to be able to inspect build output while running in debug mode. Please see the TestKit documentation for potential limitations.


Travis CI: org.gradle.launcher.daemon.client.DaemonDisappearedException: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
(Simon Herter) #5

Unfortunately the debug mode is not an option then. I want to test against Gradle versions < 2.9.

See Travis CI: org.gradle.launcher.daemon.client.DaemonDisappearedException: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed) for what I did to make Gradle work on Travis


(Sebastian Schuberth) #6

I would have expected that the GradleRunner respects an environment setting like GRADLE_OPTS="-Dorg.gradle.daemon=false", but apparently that’s not the case :frowning: