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
6
votes
1 answer

Testcontainers with Spring actuator

I would like to run a container with testcontainers on a network. My containers contains a spring application, which has an actuator endpoint to express its state, it is on: /actuator/health My container looks like the following: private final…
Five
  • 378
  • 2
  • 19
6
votes
1 answer

Spring boot with testcontainers - how to prevent DB initialization on context reload

Context I have a suite of Integration tests in a Spring boot application. The test context uses a MSSQL docker container for it's database using the testcontainers framework. Some of my tests use Mockito with SpyBean which, apparently by design,…
Matt R
  • 1,276
  • 16
  • 29
6
votes
3 answers

How to use Testcontainers Cassandra with Spring Data for Apache Cassandra?

I develop integration tests for my spring boot application, which works with Cassandra. I use CassandraTemplate for communication with Cassandra. I have the following config for the database…
6
votes
1 answer

How to create many db on one db server/container

How I can create multiple database on one mysql db container? Or Do I have to create db container per database? When I am trying to create it from sql file script: @ClassRule public static MySQLContainer dbService = (MySQLContainer) new…
masterdany88
  • 5,041
  • 11
  • 58
  • 132
6
votes
3 answers

How to create a TestContainers base test class in Kotlin with JUnit 5

I am trying to use Neo4j TestContainers with Kotlin, Spring Data Neo4j, Spring Boot and JUnit 5. I have a lot of tests that require to use the test container. Ideally, I would like to avoid copying the container definition and configuration in each…
Martin L.
  • 135
  • 1
  • 7
6
votes
2 answers

Using testcontainers in a Jenkins Docker Agent: containers fail to start, NoRouteToHostException

I'm using a Jenkins declarative pipeline with Docker Agents to build and test my software, including running integration tests using testcontainers. I can run my testcontainers tests OK in my development environment (not using Jenkins), but they…
Raedwald
  • 46,613
  • 43
  • 151
  • 237
6
votes
2 answers

How to create database in TestContainers?

I'm using this dependency: org.testcontainers postgresql 1.5.1 test this is the Container, lauched with my…
Igor
  • 478
  • 9
  • 22
5
votes
1 answer

How to pass secrets to testContainers?

I have following docker-compose file for local development: version: '3.4' networks: mynetwork: services: samba: image: instantlinux/samba-dc:latest container_name: samba-dc cap_add: - CAP_SYS_ADMIN hostname: my.org …
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
5
votes
0 answers

TestContainers Exception: Docker.DotNet.DockerApiException : Docker API responded with status code=Conflict

I have a .Net Core 6 Project which I am trying to setup integration tests for using TestContainers. I am using a Dockerfile generated by Visual Studio and this builds my image and I am able to run the container locally and the web api works as…
kolexinfos
  • 1,030
  • 1
  • 21
  • 42
5
votes
1 answer

Deserialization issue using test container pubsub emulator

I'm having an issue doing integration tests with my spring application. I'm using testcontainer to setup a pubsub emulator: @Container private static final PubSubEmulatorContainer pubsubEmulator = new…
Rlarroque
  • 1,900
  • 1
  • 17
  • 27
5
votes
3 answers

Is it possible to stop reuse test containers after all integration tests finished

I am using a singleton test-container for running multiple integration tests like this : @SpringBootTest(webEnvironment = RANDOM_PORT) public abstract class BaseIT { static final PostgreSQLContainer postgreSQLContainer; …
Catalina
  • 663
  • 5
  • 20
5
votes
3 answers

Testcontainers: docker-machine executable was not found on PATH

I have two spring boot projects both with the same JDK and running on the same machine (apple m1). The first project is just a dummy project with just testcontainer dependency in it. While the second project is a legacy project in which i was…
pankaj kumar
  • 119
  • 1
  • 1
  • 8
5
votes
1 answer

how to override image registry urls that testcontainer uses

I am getting error [ERROR] when trying to pull image through test container. Reason CI machines in your organisation have access to a common registry server and is not allowed to talk to external web. Testcontainer java has something like for this…
eswaat
  • 733
  • 1
  • 13
  • 31
5
votes
2 answers

Testcontainers start two containers instead of one in Spring boot project

I'm using Testcontainers 1.15.3 with Spring Boot 2.4 and Junit5. When I run my test, testcontainers starts the first container and execute flyway scripts and then stop the first container. Immediatly a second container is started (without launching…
jel
  • 71
  • 5
5
votes
0 answers

Testcontainers in Gitlab

I'd like to run Testontainers in Gitlab for testing Spring Boot applicaton. After I created Gitlab runner (changed URL and token): sudo gitlab-runner register -n \ --url https://gitlab.com/ \ --registration-token REGISTRATION_TOKEN \ …
bert
  • 111
  • 1
  • 8