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
2 answers

simulate network outage for database with testcontainers

I am trying to simulate a network outage with testcontainers. I wanted to use a Socat container to expose the port, and then shot it down, and up again. I couldn't manage this as there are no halt. How can I manage this?
Arash
  • 11,697
  • 14
  • 54
  • 81
3
votes
1 answer

How to override spring application properties in test classes? Spring’s @ContextConfiguration breaks when using Kotlin inner classes

I’m currently trying to change some Spring configuration properties in test code (they aren’t static, that’s why). There’s this odd thing when I try to solve my problem with @ContextConfiguration(initializers = [MyTestClass.Initializer::class]). and…
criedel
  • 346
  • 1
  • 8
3
votes
2 answers

Static container name when running Testcontainers with docker compose

My application consists of a Spring Boot app and a database. I can successfully run them in Docker using docker-compose. I now want to use a similar Docker compose file along with testcontainers to write some automated tests. I am failing because…
s1mm0t
  • 6,035
  • 4
  • 38
  • 45
3
votes
3 answers

Can't connect to Cassandra docker container in Scala Tests

I am quite desperately trying to set up docker tests in Scala. I have created an example project on GitHub to understand how should I set up the environment. It is available here: https://github.com/atais/sbt-scala-docker-cassandra I have selected…
Atais
  • 10,857
  • 6
  • 71
  • 111
3
votes
1 answer

Spring Boot Integration Tests With @MockBean don't release jdbc connections

I have a problem with integration tests. We're using spring boot 1.4.4 + spring batch + testcontainers + postgres. Each integration test annotated: @RunWith(SpringRunner.class) @ActiveProfiles(value = { "integrationtest" }) @SpringBootTest(classes…
3
votes
2 answers

How to turn off shutting down of containers in TestContainers?

I have this abstract class for IT tests: @RunWith(SpringRunner.class) @Import(DbUnitConfig.class) @SpringBootTest(classes = App.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @DbUnitConfiguration(dataSetLoader =…
Igor
  • 478
  • 9
  • 22
2
votes
1 answer

Integration tests with Kafka and Testcontainers

I am developing some integration tests for my application, and one of the flows I'm testing uses Kafka to notify some client about the updates. I have created a KafkaContainer: import org.springframework.test.context.DynamicPropertyRegistry; import…
2
votes
1 answer

How to use Spring Boot 3.1 ImportTestContainers

I tried to taste the ImportTestContainers feature in Spring Boot 3.1. All my attempts are failed. I have added the spring-boot-testcontaienrs to test scope in my project, and created a simple test to use…
Hantsy
  • 8,006
  • 7
  • 64
  • 109
2
votes
0 answers

SpringBootTest random port access in companion object

Im struggling with getting the "spring" generated random port for tests where it would be needed in a companion object for mapping my config to the proper testcontainer port @SpringBootTest(classes = [Application::class], webEnvironment =…
2
votes
5 answers

Spring Boot Integration Testing with TestContainers with MySql - BeanDefinitionStoreException

I'm trying to implement an integration test using TestContainers. But I'm continuously getting BeanDefinitionStoreException. My Test Class @SpringBootTest @AutoConfigureMockMvc class OrderServiceApplicationTests { @Container static…
2
votes
1 answer

Testcontainers for .NET error Auto discovery did not detect a Docker host configuration

I use Testcontainers.MsSql 3.0.0 for integration tests in asp.net project. Integration tests run successfully in visual studio test runner. But when I run tests in docker desktop version 20.10.7 by docker build command I get error: Auto…
vahid tajari
  • 1,163
  • 10
  • 20
2
votes
1 answer

Running testcontainers with a custom Dockerfile: no such image

FROM .artifactory..net/base/gobuilder:latest as builder ... FROM .artifactory..net/base/distroless-base: ... I have an issue with the testcontainers library. For the most part, it just runs…
Don Draper
  • 463
  • 7
  • 21
2
votes
1 answer

Error creating flyway bean with testcontainers

I have this code here that should create the container and the migrations, I've already tested using MySQLContainer instead of generic and it also showed the error, with the generic I go what arrived in that last…
2
votes
0 answers

Can't make a docker build due failing tests with testcontainers

I try to create docker image and run a container but maven build fails due failing the tests with testcontainers. Also should say that Im a windows user, but there is a Ubuntu-22.04 over Windows 10. Docker successfully finds WSL2 in settings P.S.…
2
votes
1 answer

How can I use a Webdriver Testcontainer in Bitbucket Pipelines?

When trying to use a Webdriver Testcontainer in Bitbucket Pipelines, I get the following error messages: [main] WARN [selenium/standalone-chrome:4.1.1] - Unable to mount a file from test host into a running container. This may be a misconfiguration…
JoshBBParker
  • 109
  • 1
  • 4