Tests executed with the TestKit are run in a daemon JVM. You’ll need to tell the daemon JVM to set the Java agent argument. Something like this should do:
You can set the daemon JVM parameter on the command line via system property
org.gradle.jvmargs. These JVM arguments are propagated to the daemon JVM. The drawback to this approach is that you’ll have to remember to set it every time you run the build.
Alternatively, you could use the internal
withJvmArguments(String...). Keep in mind that the method might change with future versions of Gradle.
Please note that we are planning to support Jacoco for TestKit out-of-the-box with milestone 3.