Using IntelliJ IDEA 14.0.2, I imported the gradle java project. We set sourceSet and configuration to separate integration tests from unit tests. (Our integration tests are in the test source tree, but in their own package). The corresponding bits from 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 the source of the integration test in IntelliJ and right-click to launch it, IntelliJ runs the "test" task, not the "InteTest" task. How to get IntelliJ to run the correct task?
Alternatively, how can I make the test task delegate another task based on the contents of "-tests" arg?
intellij-idea unit-testing gradle
AndyL
source share