Karmakulov Kirill
Karmakulov Kirill

Reputation: 151

spring-boot-docker-compose skips loading containers in Kotest

Test class configuration:


@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureObservability
class IntegrationFreeSpec : FreeSpec() {
    override fun extensions() = listOf(SpringExtension)
    ...

When test application starts, I see that in DockerComposeLifecycleManager's start() method skipCheck.shouldSkip(...) check evaluates to true, so the method exits. Inside the shouldSkip(...) I see that isSkippedStackElement(element) with org...SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137) argument evaluates to true, which triggers immediate method return with true. Current thread is Test worker @coroutine#2 stacktrace is here.

After playing a bit with debugger (thread = new Thread("OK) right before iteration) the containers and the test application start smoothly, all the tests pass.

  1. What was the intention behind putting org.springframework.boot.test package into the black list?
  2. Is there any workaround?

Upvotes: 0

Views: 122

Answers (1)

Scott Frederick
Scott Frederick

Reputation: 5105

As mentioned in the Spring Boot documentation:

By default, Spring Boot’s Docker Compose support is disabled when running tests.

To enable Docker Compose support in tests, set spring.docker.compose.skip.in-tests to false.

Upvotes: 1

Related Questions