Mark Gradle source folder as test source in IntelliJ : <p>I have an integration test source folder set up in gradle like so:</p>

<pre><code>subprojects {
    apply plugin: 'java'
    apply plugin: 'idea'

    sourceCompatibility = 1.8

    configurations {
        integrationTestCompile.extendsFrom testCompile
        integrationTestCompileOnly.extendsFrom integrationTestCompile
        integrationTestCompileOnly.extendsFrom testCompileOnly
        integrationTestRuntime.extendsFrom testRuntime
    }

    sourceSets {
        integrationTest {
            java {
                compileClasspath += main.output + test.output
                runtimeClasspath += main.output + test.output
                srcDir file('src/integrationTest/java')
            }
            resources.srcDir file('src/integrationTest/resources')
        }
    }

    task integrationTest(type:Test) {
        testClassesDir = sourceSets.integrationTest.output.classesDir
        classpath = sourceSets.integrationTest.runtimeClasspath
        outputs.upToDateWhen { false }
    }
}
</code></pre>

<p>For executing the tests, this works perfectly well, but it causes problems with IntelliJ's inspections, which may change behavior for test code. IntelliJ does not recognize the source folder as test source.</p>

<p>I tried adding them as such (inside <code>subprojects</code>):</p>

<pre><code>idea {
    module {
        testSourceDirs += file('src/integrationTest/java')
    }
}
</code></pre>

<p>but that did not help at all. I also tried manually marking them as test source (context menu -> mark directory as -> test sources root), but IntelliJ quickly overrides that back to normal source root.</p>

<p>How do I configure this correctly in Gradle?</p>

<p>I'm using IntelliJ 2016.1.3 and Gradle 2.14.1 on Ubuntu 16.04</p>
