Questions tagged [testcontainers-junit5]
89 questions
1
vote
1 answer
Problem using Spring Cloud Vault with @DynamicPropertySource
When using TestContainers to start a Vault container, the port that is exposed by the container is randomly selected during startup.
@Container
static VaultContainer vaultContainer = new VaultContainer<>("vault:1.7.2")
.withVaultToken(TOKEN)
…
1
vote
1 answer
JUnit 5 tests not detected when TestContainers dependencies exist in pom.xml
I have a maven project the uses both TestContainers (latest 1.5.2) and JUnit 5 (5.7.0) tests. Surefire plugin set to version 2.22.2 (see full POM below). Maven version is 3.6.0 and using Java 11.
I created two test classes: one uses JUnit 4.12…

Danny Cohen
- 51
- 1
- 4
1
vote
1 answer
Create a folder inside a postgres testcontainer before init script
I have the following piece of code:
public static PostgreSQLContainer> postgreDBContainer = new PostgreSQLContainer<>("postgres:12")
.withInitScript("init-database-test.sql")
.withUsername("dba")
…

Marcus Hert da Coregio
- 4,635
- 9
- 27
1
vote
1 answer
Why does TestContainer use a wrong URL (missing 'tc')?
I intend to test database access utilizing Testcontainer (version 1.15.2) with Kotlin 1.4.31 and I have a test class...
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import…

du-it
- 2,561
- 8
- 42
- 80
1
vote
1 answer
spring boot kafka failed with "Broker may not be available" while using testcontainers with kafka, zookeeper, schema registry
I've run testcontainers like below in the test code.
@Testcontainers
public class TestEnvironmentSupport {
static String version = "5.4.0";
static DockerImageName kafkaImage =…

yaboong
- 157
- 3
- 18
1
vote
4 answers
How to test repository with junit5 and testcontainers?
I have a sample project in which I experiment with different technologies.
I have the following setup:
Spring Boot 2.3.4.RELEASE
Flyway 7.0.1
Testcontainers 1.15.0-rc2
Junit 5.7.0
How can I test the Repository layer with…

Dmytro Chasovskyi
- 3,209
- 4
- 40
- 82
0
votes
0 answers
mySQLTestcontainer can't chown /etc/mysql/conf.d folder inside rootless podman container
Problem
I want to start a MySQLContainer from a junit test with mvn clean verify. But for some reason it can't chown the container folder for my host user.
Here is a screenshot that illustrates the…

Jo Vanmont
- 41
- 4
0
votes
0 answers
Testcontainers providing connection to ibm/mq
I got following service bean that picks up connection and destination from JBoss standalone configuration file when deployed.
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import…

Martin
- 411
- 8
- 21
0
votes
0 answers
Testcontainers parallel tests
I have a multi module Gradle project where I use testcontainers for the integration tests.
My initial idea was to share a container for all tests to run against the issue is that each test suite starts it´s own container.
I used the Singleton…

esfomeado12
- 11
- 5
0
votes
0 answers
Using a new PostgreSQLContainer test container for each class in a test suite
I am new to integration testing and I am trying to run a suite of tests in a spring boot project using PostgreSQLContainers from the Testcontainers library.
The structure of the suite looks like this:
Suite
@SpringBootTest First Class
@Test…

Tyler
- 1
0
votes
1 answer
how to see PostgreSQLContainer database records
I have created PostgreSQLContainer as below
public static PostgreSQLContainer postgres = (PostgreSQLContainer) new PostgreSQLContainer<>("postgres")
.withCreateContainerCmdModifier(cmd -> cmd.withName("postgres-sql"))
…

Abdullah Imran
- 259
- 3
- 13
0
votes
1 answer
Testcontainer ContainerLaunchException: Container startup failed
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.utility.DockerImageName;
@Slf4j
public class…

emoleumassi
- 4,881
- 13
- 67
- 93
0
votes
1 answer
Testcontainers: communication between containers
I have 2 testcontainers, one which is a dynamodb instance, and the second one a spring-boot one that needs to connect with the first one.
While running locally I was just connecting from spring-boot => dynamodb using localhost:8000 , which won't…

gregory mayers
- 3
- 3
0
votes
0 answers
How spring boot integration test cooperates with testcontainers
I have a general question about the relationship between integration tests in spring boot and testcontainers library. I will use example to illustrate the situation.
I am using testcontainers as described here:…

mdm
- 13
- 4
0
votes
0 answers
Populate a Testcontainer database in pom.xml
In some scecific usescases like the interaction with jooq-codegen-maven, it is necessary to initialize a Database from Maven.
One alternative could be the usage of flyway, but how to use only testcontainers with the method: .withInitScript? Using…

jabrena
- 1,166
- 3
- 11
- 25