I am using Spring Boot + Gradle + Spock (groovy) for integration and unit testing.
I was able to configure unit tests to work with Spock.
Integration tests fail to start because they do not see project files.
Here configuration I've done (cleaned up) for integrationtests.
I do believe issue is that I don't configured dependency properly + that integration tests in different directory.
sourceSets {
integrationTest {
groovy.srcDir "$projectDir/src/integrationTest/groovy"
resources.srcDir "$projectDir/src/integrationTest/resources"
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
}
task integrationTest(type: Test) {
description = 'Runs the integration tests.'
group = 'verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
}
Directory structure is
src
-main
--java
-test
--groovy
-integrationTest
--groovy
Given that you are on a new enough Gradle version, I recommend you use the JVM Test Suite Plugin to define your additional test suite. It is documented at https://docs.gradle.org/current/userguide/jvm_test_suite_plugin.html and also shows your exact use-case, integration tests that need access to production code.