Skip to content

Instantly share code, notes, and snippets.

Created March 2, 2021 14:43
What would you like to do?
Starting TestContainers and modifying config at startup in a Micronaut project
package com.example
import groovy.util.logging.Slf4j
import org.testcontainers.containers.GenericContainer
import org.testcontainers.utility.DockerImageName
import spock.lang.Specification
abstract class IntegrationSpec extends Specification implements TestPropertyProvider {
static GenericContainer redisContainer = new GenericContainer(DockerImageName.parse("redis")).withExposedPorts(6379)
static {
Map<String, String> getProperties() {
String redisUrl = "redis://${}:${redisContainer.firstMappedPort}"
log.debug("Providing redis connection URL ${redisUrl}")
"redis.uri": redisUrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment