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

Elasticsearch and Testcontainers for testing "None of the configured nodes are available"

I try to write test using elasticsearch container. I run it with https://www.testcontainers.org/ library. That's my configuration: @ClassRule public static GenericContainer elasticContainer = new…
knalx
  • 171
  • 1
  • 5
7
votes
1 answer

TestContainers integration test on Gitlab CI

I have java project which using testcontainers for integration test. I want to implement gitlab ci for that stage but I've got that error java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check…
neoerol
  • 911
  • 1
  • 12
  • 18
7
votes
2 answers

Testcontainer cannot configure port binding

I'm using testcontainer version 1.15.2. Tests are run in intellij on windows 10. I have a wiremock container. By default it listens on the port 8080. I would like to map this port to let's say 8081. So I do: public WiremockContainer() { …
7
votes
1 answer

How to combine Testcontainers with @DataJpaTest avoiding code duplication?

I want to use Testcontainers with @DataJpaTest (and @SpringBootTest) using JUnit 5. I have the basic setup working using the @Testcontainers and @Container annotation like this: import org.junit.jupiter.api.Test; import…
Wim Deblauwe
  • 25,113
  • 20
  • 133
  • 211
7
votes
1 answer

Spring @Sql Annotations, possible to run once before all tests?

Using Spring for integration tests I am able to populate a test DB running scripts like so... @Test @Sql({"/db/schema.sql", "/db/accountConfig.sql", "/db/functions/fnSomething.sql"}) public void verifySomething() { ... } However, I'd like to run…
HelloWorld
  • 4,251
  • 8
  • 36
  • 60
7
votes
1 answer

github actions for running test with testcontainers and gradle

I'm new to github actions (comming from gitlab-ci) I'm trying to run a integration test with testcontainers in the pipeline and I'm stucked. Here is my current definition. name: Run Gradle on: push jobs: gradle: strategy: matrix: …
imalik8088
  • 1,501
  • 5
  • 21
  • 39
7
votes
1 answer

How to copy executable file to Docker container using Testcontainers

I'm trying to copy an executable initialization bash script init.sh to the Localstack Docker container created with Testcontainers (1.13.0) using the JUnit 5 module: @Container static LocalStackContainer localStack = new…
rieckpil
  • 10,470
  • 3
  • 32
  • 56
7
votes
1 answer

Testcontainers ; Running @Testcontainers Tests inside docker [Running Docker inside Docker]

How To Run @Testcontainers based test cases inside the docker container ? I have Simple Spring Boot App that has Integration Test (Component level) that are interacting with containers using Testcontainers. Test cases are ruining fine from outside…
Niraj Sonawane
  • 10,225
  • 10
  • 75
  • 104
7
votes
2 answers

SpringbootTest + TestContainers: how do I refresh the database after tests pollute the database

I am using an abstract class like this: @SpringBootTest(classes = MyAppApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public abstract class AbstractIntegrationTest { static { PostgreSQLContainer…
user952342
  • 2,602
  • 7
  • 34
  • 54
7
votes
2 answers

Testcontainer's Redis container connects to a different container then the one defined in the test

I'm doing integration tests in my Spring Boot app. The app needs a Redis to work with. During development phase, I have a local container of Redis that the app connects to. For the integration tests, I'm using testcontainers and I also followed…
riorio
  • 6,500
  • 7
  • 47
  • 100
6
votes
2 answers

Run dotnet tests in docker which use testcontainers

I have an integration tests project that executes as expected in VS. The integration tests use a MsSql testcontainer (from https://dotnet.testcontainers.org/). My goal is to run these tests in an Azure DevOps pipeline within a docker image, as I do…
JoaoRibeiro
  • 808
  • 7
  • 24
6
votes
1 answer

AWS CodeBuild: How to run tests that require starting Docker?

I have a Node.js project with Testcontainers used for staring Redis and Prostgress for tests. I want to run these tests as a part of CI. For that purpose, I use an alpine image of Node.js with Docker installed on top of it. I can run tests that…
Sasha Shpota
  • 9,436
  • 14
  • 75
  • 148
6
votes
1 answer

How can I set the port for Postgresql when using Testcontainers?

Sometimes I need to install a port for Postgresql, which I run for tests in a container. But the Test container the developer command ofTestcontainers removed this feature. But somewhere there is a workaround solution, through the settings, but I…
skyho
  • 1,438
  • 2
  • 20
  • 47
6
votes
0 answers

Testcontainers: FileNotFoundException: .testcontainers.properties

I am getting issues with running integration tests (using JUnit5) of my micronaut app on my Windows 10 Pro machine. My tests depend on two containers, that I defined using Testcontainers java library: RabbitMQ and MS SQL server. The Docker version…
Hutsul
  • 1,535
  • 4
  • 31
  • 51
6
votes
3 answers

java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration

I have a docker image called myImageName:latest, which I use in my application. I want to write an integration test for my application, therefore I want to use the TestContainer package. When I run the following simple test: @Testcontainers public…
Oded
  • 336
  • 1
  • 3
  • 17
1 2
3
58 59