Has anyone used TestContainers with Kotlin+JUnit? ...
# announcements
a
Has anyone used TestContainers with Kotlin+JUnit? I'm trying to use it for spinning up a redis container that's controlled by the test suite
ended up solving this myself
Copy code
import org.testcontainers.containers.GenericContainer
import org.testcontainers.containers.wait.strategy.Wait

class KGenericContainer(imageName: String): GenericContainer<KGenericContainer>(imageName)

object RedisContainer {
    val instance by lazy { startRedisContainer() }

    private fun startRedisContainer() = KGenericContainer("redis:5.0.3-alpine").apply {
        withExposedPorts(6379)
        setWaitStrategy(Wait.forListeningPort())
        start()
    }
}