I am using Gradle 1.3.
I have this canonical intTest-type task
sourceSets {
intTest {
compileClasspath = sourceSets.main.output + configurations.testRuntime
runtimeClasspath = output + sourceSets.main.output + configurations.testRuntime
}
}
test {
useTestNG()
}
task intTest(type: Test) {
useTestNG()
testClassesDir = sourceSets.intTest.output.classesDir
classpath = sourceSets.intTest.runtimeClasspath
outputs.upToDateWhen { false }
install.enabled = false
uploadArchives.enabled = false
}
imported into a subproject build using
apply from: file("${rootDir}/gradle/inttest.gradle")
Most of my integration tests use TestNG. Hence my desire to default the task config to that using useTestNG().
However, there is a different subproject integration test that needs to use JUnit. I tried this, after the ‘apply from’, in that oddball subproject’s build.gradle to try to force JUnit:
intTest.doLast {
useJUnit()
...
}
but the JUnit-based tests do not run. As if by the time the call to useJUnit() is made, it’s too late to configure the task.
Is it too late by this point to customize the intTest task? If not, what is a good way to achieve this late-binding of the task test runner to JUnit?
Thanks.