I would like to add integration tests to my spring boot application. Currently I don't have unit tests but I want to keep the standard project layout:
├── Demo
│ ├── src
│ │ ├── main
| | | └──java
│ │ ├── integrationTest
| | | └──java
│ │ ├── test
| | | └──java
My questions are:
Should I create integrationTest folder as module? If so - why? and how can I do it in intellij?
'main' and 'test' are already defined as modules under 'Demo' which is also defined as module.
I've tried several times to set it via 'Project Structure' but it wasn't created under 'Demo' and caused to a mess by creating a different src folder and another build.gardle file
and when I succeeded to create it under 'Demo', it added a new line to setting.gradle file: include 'integrationTest'
I'm really confused with it.
Can anyone help me how to create this submodule (if needed)?
Thanks
I'll put here the solution for people who encounter the same problem.
Creating a module for integrationTest (add the following to build.gradle
):
sourceSets {
integrationTest {
java.srcDir file("src/integrationTest/java")
resources.srcDir file("src/integrationTest/resources")
runtimeClasspath += sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath
compileClasspath += sourceSets.main.compileClasspath + sourceSets.test.compileClasspath
}
}
Mark it as 'Test Source' in Intellij:
plugins {
// ...
id 'idea'
}
// ...
idea {
module {
sourceSets.integrationTest.allSource.srcDirs.each { srcDir -> module.testSourceDirs += srcDir }
}
}
// ...