mardi 3 février 2015

How to run integration tests from IntelliJ context menu for gradle project?

Using IntelliJ IDEA 14.0.2, I have imported a gradle java project. We have 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 the 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 the source of an integration test in IntelliJ and right-click to run it, IntelliJ launches the "test" task rather than the "integTest" task. How do I get IntelliJ to launch the correct task?


Alternatively, how can I make the test task delegate to another task based on the contents of the "--tests " arg?


Aucun commentaire:

Enregistrer un commentaire