Using IntelliJ IDEA 14.0.2, I have imported a gradle java project. I've set up a sourceSet and configuration to separate integration tests from unit tests. (our integration tests are in the test source tree, but in their own package). Relevant bits from my build.gradle are:
sourceSets { test { java { exclude '**/it/**' } } integTest { java { srcDir 'src/test/java' include '**/it/**' } resources { srcDir 'src/test/resources' } compileClasspath += sourceSets.main.output + sourceSets.test.output + configurations.testRuntime runtimeClasspath += sourceSets.main.output + sourceSets.test.output + configurations.testRuntime }
}
configurations {
integTestCompile.extendsFrom testCompile integTestRuntime.extendsFrom testRuntime
}
idea {
module { scopes.TEST.plus += [ configurations.integTestCompile ] }
}
task integTest(type: Test) {
testClassesDir = sourceSets.integTest.output.classesDir classpath = sourceSets.integTest.runtimeClasspath
}
This works fine from the command line. But when I open up an integration test in IntelliJ and right-click to run it, IntelliJ launches the test task instead of the integTest task. How do I get IntelliJ to launch the correct task?
I can manually modify the run config for each test, but that doesn't scale to multiple developers and many test classes.
This seems like a very common use case to me, but I haven't found anything much in my searching so far.
--Andy