Questions tagged [testcontainers]

TestContainers is a Java library that supports (JUnit) tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.

Testcontainers is an open source framework for providing throwaway, lightweight instances of databases, message brokers, web browsers, or just about anything that can run in a Docker container.

Define your test dependencies as code, then simply run your tests and containers will be created and then deleted.

https://www.testcontainers.org/

881 questions
3
votes
1 answer

How to use different ports using Couchbase Java SDK 3

Context: I'm writing some integration tests using docker (using testcontainers). And I want to connect to couchbase using toxiproxy. The problem: I can't connect to couchbase using different ports than the default ones. The docs says to just use…
Eric Sant'Anna
  • 267
  • 4
  • 17
3
votes
2 answers

how to override an application property programatically in Quarkus

I've recently started using testcontantainers for unit/integration testing database operations in my Quarkus webapp. It works fine except I cannot figure out a way to dynamically set the MySQL port in the quarkus.datasource.url application property.…
kosmičák
  • 1,043
  • 1
  • 17
  • 41
3
votes
0 answers

MongoDBContainer not starting for Spring Boot Integration tests

Update 2 By adding environment variables for setting up the container manually, the admin user gets created successfully. When starting a SpringBootTest which uses a MongoDBContainer, the database in the container was not accessible - this is fixed…
Florian Salihovic
  • 3,921
  • 2
  • 19
  • 26
3
votes
0 answers

Testcontainers + dbrider: Could not clear table X, message:Cannot commit when autoCommit is enabled., cause: null

Having a simple Spring boot app, with following integration test configuration: @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestPropertySource(ResourceUtils.CLASSPATH_URL_PREFIX +…
Tom
  • 192
  • 1
  • 1
  • 7
3
votes
3 answers

How do I get Java testcontainers to work in Docker Multistage builds?

I have a problem similar to Run (Docker) Test Container in gitlab with Maven. The difference is that rather than my script running mvn directly it runs a docker multistage build that runs the test inside of the docker image. Unfortunately this…
Raymond
  • 406
  • 3
  • 9
3
votes
2 answers

Running test with testcontainers as part of a Dockerfile

My dockerfile looks something like this: FROM maven:3-jdk-11-slim COPY pom.xml . COPY src src RUN mvn clean install That means that part of the build is the execution of the unit tests. Some of the unit tests use a testcontainer. Running mvn clean…
michel404
  • 473
  • 4
  • 12
3
votes
1 answer

Can't Get Docker Image

I have 5 spring batch tests I am running on a Jenkins pipeline using testcontainers. I am getting the following error only on ONE of the tests: 12:51:53 17 Mar 2020;17:51:41.498 [user:] [request:] [main] INFO 12:51:53 …
Ashwin Jacob
  • 187
  • 2
  • 2
  • 15
3
votes
0 answers

Testcontainers hanging when using docker-compose on gitlab-ci

I've used testcontainers on gitlab before(Rabbitmq container) but now using DockerComposeContainer. However we consistently see it hang here: . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_…
user3465651
  • 706
  • 1
  • 4
  • 22
3
votes
1 answer

Failed to connect to PostgreSQLContainer: java.io.EOFException

Creating my container as: public static PostgreSQLContainer container = new PostgreSQLContainer<>("postgres:latest"); static { container.start(); System.setProperty("driver-class-name", container.getDriverClassName()); …
Tyulpan Tyulpan
  • 724
  • 1
  • 7
  • 17
3
votes
1 answer

Why does my Testcontainers test hang till timeout on "Waiting for database connection to become available at"?

When constructing a JUnit test using Testcontainers my test hangs until timeout after the message "Waiting for database connection to become available at" and the container logs, then helpfully shown, do not yield any error. I can even connect to…
gkephorus
  • 1,232
  • 18
  • 31
3
votes
1 answer

why the test container with the RabbitMQ is creates every time anew and is not shared between the tests

I have 4 tests for listeners, the application is built on SpringBoot and uses Testcontainers, I run mvn clean install, and I get the following: 9-08-15 18:37:01.287 INFO 8312 --- [tContainer#1-11] o.s.a.r.c.CachingConnectionFactory :…
M Nikita
  • 33
  • 1
  • 5
3
votes
3 answers

How can I run Integration Test to Kafka with Testcontainer using Junit 5

I'm trying to write an integration test for my Kafka consumer. I'm using JUnit 5, so I can׳t initialize it using @Rule, and the examples I saw with @Container initialization it is not working as well. I tried to change my Junit version to Junit 4…
reut
  • 241
  • 1
  • 3
  • 11
3
votes
1 answer

testcontainers-go: p.client.DaemonHost undefined

I am trying to add TestContainers-Go to my project. I use glide and TestNginxLatestReturn example from Github readme file. In glide I put - package: github.com/testcontainers/testcontainers-go version: v0.0.3 but at runtime I get this error in…
Nikolay Kuznetsov
  • 9,467
  • 12
  • 55
  • 101
3
votes
1 answer

Issue when executing Gitlab CI pipeline job running integration test with Testcontainers

I have a Spring Boot application test that used TestContainers (https://www.testcontainers.org) to run some integration tests against a KafkaContainer. When running locally everything is fine, but when running integration test inside a GitlabCI…
3
votes
3 answers

Error when using TestContainers DB via JDBC URL but works with @Rule

I'm trying to use TestContainers for my integration tests. I started using it instantiating objects like: @ClassRule public static PostgreSQLContainer postgres = (PostgreSQLContainer) new PostgreSQLContainer() .withDatabaseName("producto") …
Rayniery
  • 1,557
  • 2
  • 12
  • 17