I am trying to convert a maven project to gradle, and am struggling to get integration tests running. I am trying to use the recommended JVMTestSuite plugin, but the integration tests do not run correctly.
Using the example on the documentation, the current setup I have is this:
testing {
suites {
test {
useJUnitJupiter()
}
integrationTest(JvmTestSuite) {
testType.set(TestSuiteType.INTEGRATION_TEST)
dependencies {
implementation project()
}
targets {
all {
testTask.configure {
shouldRunAfter(test)
}
}
}
}
}
}
tasks.named('check') {
dependsOn(testing.suites.integrationTest)
}
When I run ./gradlew integrationTest, the build succeeds but no tests are being executed. When I run ./gradlew test, all the unit tests and integration tests run, but the integration tests fail as the Spring context is not set up correctly.
End result I would like is:
testcommand runs only unit testsintegrationTestsets up Spring context and executes tests- Each set of tests is filtered by name (eg. filtering "*IT.java" rather than using separate folder structures)
Is someone able to help with this? The documentation does not seem to lead to a working example. Thank you :)