The documentation for Docker Compose support includes this note:
By default, Spring Boot’s Docker Compose support is disabled when running tests. To enable it, set spring.docker.compose.skip.in-tests to false.
We should also suggest that Gradle users change their build configuration from developmentOnly("org.springframework.boot:spring-boot-docker-compose") to testAndDevelopmentOnly("org.springframework.boot:spring-boot-docker-compose") when using Docker Compose for tests.
Comment From: doxxx93
Also, I think that it would be better if there were additional comment. for example
By default, Spring Boot’s Docker Compose support is disabled when running tests. To enable it, set spring.docker.compose.skip.in-tests to false and add testImplementation dependency to your build.gradle file.
Comment From: fatso83
@doxxx93 The testAndDevelopment bit is really what is missing here IMHO, so should not forget about that.
Comment From: YangSiJun528
The testAndDevelopmentOnly configuration is a new feature introduced in Spring Boot 3.2, so it's not available in Spring Boot 3.1.
For users of Spring Boot 3.1, the documentation should suggest using the developmentOnly configuration along with the testImplementation dependency to enable the Docker Compose support when running tests.
Comment From: fatso83
@YangSiJun528 Is it possible to use both configurations simultaneously? I thought it would have to be one or the other? You just duplicate the line like this or what? As in
dependencies {
developmentOnly("org.springframework.boot:spring-boot-docker-compose")
testImplementation("org.springframework.boot:spring-boot-docker-compose")
}
? I think this should be quite explicit, in that case, not ever having seen that.
Comment From: YangSiJun528
@fatso83, Yes, can use them simultaneously. I was actually using developmentOnly and testImplementation together before I discovered this issue.
However, if that seems unconventional there might be other viable configuration options as well.
The key point I was trying to make is that for Spring Boot 3.1, testAndDevelopmentOnly is not an option, so an alternative approach is necessary.
Comment From: doxxx93
Yeah I did so. It works well in 3.2 too.