I develop a Gradle plugin and in my project I inject the code under test into the test build in a manner that differs from one mentioned in https://docs.gradle.org/2.9/userguide/test_kit.html#N14FD7
I use a system property and a doFirst() block instead of a classpath file and a separate task. Also I exclude dependencies on a local Gradle API and Groovy to prevent interference with a Gradle version passed to a GradleRunner.
For me my approach looks more clean and simple than one from the user guide (no interaction with filesystem, no redundant dependencies on classpath, no new tasks), so I wonder why the user guide’s method is so complicated? Maybe I’ve overlooked something and my code has some flaws?
Here is my test configuration from build.gradle
:
{
doFirst
{
def classpathFiles = project.sourceSets.main.output.files + configurations.runtime.files -
configurations.detachedConfiguration(dependencies.gradleApi(), dependencies.localGroovy())
systemProperties = ['test.classpath.files': classpathFiles.collect{it.canonicalPath}.join(';')]
}
}```