Gradle: additional test source folders
Answered
Our workflow is to create our project configuration in gradle and then import to IDEA using IDEA gradle support, rather than using the gradle IDEA plugin to generate the project/modules.
We are trying to set up multiple test source sets to support unit and integration testing. We add the integration-test sourceSet:
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
}
IDEA picks up the new sourceSet as "source folders" (blue) rather than "test source folders" (green). Is there a way to force IDEA to import this sourceSet as test source folders (and resources)?
Please sign in to leave a comment.
Please check https://youtrack.jetbrains.com/issue/IDEA-151925#comment=27-2355076.
I struggle to make this work, without success. I have added configuration based on the suggestion in the comment link above, but IDEA still picks up src/it/scala as a Source folder and src/it/resources as Resources folder.
I use IDEA 2018.1.3 and Gradle 4.8.
Any suggestions?
If you want to mark the `scala` plugin source folders of the project as the tests add them to `testSourceDirs` as well:
Yes, that is what I did. It simply doesn't work. I'll try to create a public repo that exposes the problem.
Any update on this? in my case the IDEA is marking the integration tests source folder as green but it is not using the Gradle Test runner to run them, but uses the internal test runner
You can use the corresponding Gradle task from the Gradle projects tool window to run the tests via Gradle Test runner. Another option is to delegate build/run actions to Gradle.
I am delegating to Gradle, this is only working for the tests in the `test` source folder but not in other source folders.
It is using the IDEA tests runner even if i configure it to use the gradle one
If this setting has no effect (https://i.imgur.com/ZGnlnRJ.png), please file a bug at https://youtrack.jetbrains.com/issues/IDEA with the sample project to reproduce attached.
It is working only for tests in the test source set.
Done, https://youtrack.jetbrains.com/issue/IDEA-195896