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
10
votes
3 answers

TestContainers PostgreSQLContainer with Kotlin unit test: "Not enough information to infer type variable SELF"

I am trying to use PostgreSQLContainer from TestContainers (https://github.com/testcontainers/testcontainers-java + https://www.testcontainers.org/) in order to unit test my JPA repositories. I declare my container like that: private val…
veben
  • 19,637
  • 14
  • 60
  • 80
10
votes
1 answer

How to launch Informix via testcontainers?

I'm very interested in using testcontainers in my project. However, I'm having a hard time setting it up to work with Informix. Note that I can start an informix container using Docker-for-Mac and it will build and start. Not sure it can work…
slashdottir
  • 7,835
  • 7
  • 55
  • 71
9
votes
1 answer

GitHub Actions: How can I cache the Docker images for Testcontainers?

I execute some tests in GitHub Actions using Testcontainers. Testcontainers pulls the images which are used in my tests. Unfortunately the images are pulled again at every build. How can I cache the images in GitHub Actions?
Oliver
  • 353
  • 1
  • 4
  • 16
9
votes
0 answers

Change file's owner when copying resources with testcontainers

I'm using testcontainers in Java tests. To configure application in container I need to put and mount configuration files: some files are static, so I'm mounting them using withClassPathResourceMapping when creating new…
Kirill
  • 7,580
  • 6
  • 44
  • 95
9
votes
1 answer

Localstack throws The security token included in the request is invalid

I use Localstack with Testcontainers((testcontainers:localstack:1.15.2 )) for integration tests and set up the secret in the test setup like this: Code sample import com.amazonaws.services.secretsmanager.AWSSecretsManager; import…
9
votes
2 answers

testcontainer initializationError while running a test suite

I have multiple test classes running the same docker-compose with testcontainer. The suite fails with initializationError although each test passes when performed separately. Here is the relevant part of the stacktrace occuring during the second…
aiqency
  • 1,015
  • 1
  • 8
  • 22
9
votes
6 answers

How to clean database tables after each integration test when using Spring Boot and Liquibase?

I have a side project were I'm using Spring Boot, Liquibase and Postgres. I have the following sequence of tests: test1(); test2(); test3(); test4(); In those four tests I'm creating the same entity. As I'm not removing the records from the table…
Julian Espinel
  • 2,586
  • 5
  • 26
  • 20
9
votes
2 answers

How GenericContainer from test containers should be parametrised?

I am getting errors in my IDE about: Raw use of parameterized class 'GenericContainer' Inspection info: Reports any uses of parameterized classes where the type parameters are omitted. Such raw uses of parameterized types are valid in Java, …
masterdany88
  • 5,041
  • 11
  • 58
  • 132
9
votes
1 answer

Run tests in docker container using TestContainers and Jenkins (docker.sock Permission denied)

In my tests I use TestContainers. I want run tests in container using Jenkins. I created this image for run tests with maven. Dockerfile: FROM registry.company.com/maven:3-jdk-8-slim RUN apt update RUN apt install -y wget libatomic1 curl gnupg RUN…
All_Safe
  • 1,339
  • 2
  • 23
  • 43
9
votes
2 answers

How do you include postgresql.conf on docker container when using org.testcontainers

Is it possible to give postgresql testcontainer a custom postgresql.conf file via config? I have included maven dependency org.testcontainers postgresql
Melissa
  • 812
  • 2
  • 10
  • 24
9
votes
1 answer

Dropwizard integration testing with Testcontainers

I'm trying to run dropwizard's integration tests against a dockered database. Dropwizard Testcontainers What I've tried: @ClassRule public static final PostgreSQLContainer postgres = new PostgreSQLContainer(); @ClassRule public final…
user3960875
  • 965
  • 1
  • 13
  • 24
8
votes
2 answers

How to run Testcontainers with in-memory filesystem TMPFS set in Quarkus

I have the following issue. In order to speed up the integration test pipeline I want to run testcontainers with Quarkus with TMPFS option set. This will force testcontainers to run the DB with a in-memory file system. This can be easily done…
Arthur Klezovich
  • 2,595
  • 1
  • 13
  • 17
8
votes
0 answers

Elastic search TestContainers Timed out waiting for URL to be accessible in Docker

Local env: MacOS 10.14.6 Docker Desktop 2.0.1.2 Docker Engine 19.03.2 Compose Engine 1.24.1 Test containers 1.12.1 I'm using Elastic search in an app, and I want to be able to use TestContainers in my integration tests. Sample code in a Play…
Davis Mariotti
  • 574
  • 1
  • 4
  • 23
8
votes
4 answers

Configuring Minio server for use with Testcontainers

My application uses Minio for S3-compatible object storage, and I'd like to use the Minio docker image in my integration tests via Testcontainers. For some very basic tests, I run a GenericContainer using the minio/minio docker image and no…
otto.poellath
  • 4,129
  • 6
  • 45
  • 60
8
votes
1 answer

Can Testcontainers create docker network for me if it does not exist?

Looks like I need a network because I would like to reference one container by hostname from another. I could also use the --link but it is deprecated and can disappear soon. That's why I wonder if Testcontainers can create a docker network for…
Kirill
  • 6,762
  • 4
  • 51
  • 81
1
2
3
58 59