GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Desktop
  • Cloud
  • Getting Started
  • Guides
  • Modules
  • Java
  • Go
  • .NET
  • Node.js
  • Python
  • Rust
  • Ruby
  • PHP
  • Haskell

This view

  • Original page
  • New address

GeezerVison is showing testcontainers.com — Testcontainers

Unit tests with real dependencies

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

Test dependencies as code

No more need for mocks or complicated environment configurations. Define your test dependencies as code, then simply run your tests and containers will be created and then deleted.

With support for many languages and testing frameworks, all you need is Docker.

Get started with Java Get started with Go Get started with .NET Get started with Node.js Get started with Python Get started with Rust Get started with Haskell Get started with Ruby Get started with Clojure Get started with Elixir Get started with PHP Get started with Native
GenericContainer redis = new GenericContainer("redis:5.0.3-alpine")
    .withExposedPorts(6379);
container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
    ContainerRequest: testcontainers.ContainerRequest{
        Image:        "redis:5.0.3-alpine",
        ExposedPorts: []string{"6379/tcp"},
        WaitingFor:   wait.ForLog("Ready to accept connections"),
    },
    Started:          true,
})
RedisContainer redisContainer = new RedisBuilder().Build();
await redisContainer.StartAsync();
const redis = await new GenericContainer("redis:5.0.3-alpine")
    .withExposedPorts(6379)
    .withWaitStrategy(Wait.forLogMessage("Ready to accept connections"))
    .start();
redis = (
    DockerContainer("redis:5.0.3-alpine")
        .with_exposed_ports(6379)
)
redis.start()
wait_for_logs(redis, "Ready to accept connections")
let redis = GenericImage::new("redis", "7.2.4")
    .with_exposed_port(6379)
    .with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
    .start();
redis <-
  run $
    containerRequest (TestContainers.fromTag "redis:5.0.3-alpine")
      & setExpose ["6379/tcp"]
      & setWaitingFor (waitUntilMappedPortReachable "6379/tcp")
redis = Testcontainers::DockerContainer.new("redis:5.0.3-alpine").with_exposed_port(6379)
redis.start
(def container (-> (tc/create {:image-name "redis:5.0.3-alpine")
                               :exposed-ports [6379]})
                   (tc/start!)))
{:ok, _} = Testcontainers.start_link()
config = %Testcontainers.Container{image: "redis:5.0.3-alpine"}
{:ok, container} = Testcontainers.start_container(config)
$container = (new RedisContainer())->start();

$redis = new \Redis();
$redis->connect($container->getHost(), $container->getFirstMappedPort());
int requestId = tc_new_container_request(DEFAULT_IMAGE);
tc_with_exposed_tcp_port(requestId, 8080);
tc_with_wait_for_http(requestId, 8080, "/__admin/mappings");
tc_with_file(requestId, "test_data/hello.json", "/home/wiremock/mappings/hello.json");
struct tc_run_container_return ret = tc_run_container(requestId);
int containerId = ret.r0;
if (!ret.r1) {
    printf("Failed to run the container: %s\n", ret.r2);
    return -1;
}
Modules

Test Anything You Can Containerize: Database, Message Broker, And More

See all 50+ Modules
Use cases

How Testcontainers® can help you

Data access layer integration tests

Use a containerized instance of your database to test your data access layer code for complete compatibility, without requiring a complex setup on developer machines. Trust that your tests will always start with a known state.

UI/Acceptance tests

Use containerized web browsers, compatible with Selenium, to run automated UI tests. Each test gets a fresh, clean instance of the browser, without having to worry about variations in plugins or required updates.

Application integration tests

Run your application in a short-lived test mode with dependencies, such as databases, message queues or web servers, to give you a rich interactive and explorative testing environment.
Get started

Supported Languages

There are implementations of Testcontainers® in all of your favorite languages. Click through to read their specific documentation.
Java Go .NET Node.js Python Rust Ruby PHP Haskell Clojure Elixir Scala Native
Industry standard

Companies using Testcontainers

Spotify JetBrains Netflix Uber CapitalOne Elastic Wise Zalando Skyscanner Playtika
Articles About Testcontainers
engineering.atspotify.com
Announcing the Recipients of the 2023 Spotify FOSS Fund
Testcontainers was also part of last year’s fund, receiving 13,000 EUR. And there’s a good reason why it’s back in 2023
devblogs.microsoft.com
Trying out MongoDB with EF Core using Testcontainers
An introduction to the MongoDB database provider for EF Core, including use of Testcontainers
uber.com
Handling Flaky Unit Tests in Java
Building a stable and reliable testing system is often a key requirement for software development organizations
doordash.engineering
How to Boost Code Coverage with Functional Testing
Introducing a non manual functional testing approach that can be run like unit tests locally or in a Continuous Integration (CI) pipeline.
capitalone.com
Testcontainers & LocalStack for Spring Boot functional tests
A guide from Capital One to using Docker and Testcontainers to make functional tests more portable & economical without sacrificing testing quality.
cloud.google.com
Develop and Test Spring Boot Applications Consistently
Learn how to consistently build and test with environment parity from development to production with Emulators and open-source Testcontainers.
A huge thankyou to our sponsors

Gold Sponsors

CodeRabbit

Bronze Sponsors

Bytebase Elastic Sponsorship Galaxy TestMu AI N-iX Route4Me

Donors

GitHub Gradle Develocity Red Hat Spotify

Backers

Arkadius Jonczek Doma Karl Heinz Marbaise M. Toyokura Philip Riecks Steven Kuhn sugawani XDEV Software

Past Sponsors and Backers

American Express Amitosh Swain Mahapatra Backbase Bas Stoker Brian Heineman ByoungUk Lee Christoph Dreis CirrusCI David Liu DevOpsCon Frederik Hahne Gaurav Mukherjee InterviewPal JOOQ Josh (joshchoo) Komapper Mercedes-Benz Group minimumdepositcasinos.org Nikita Zhevnitskiy Oleg Nenashev Open Elements Oscar Veldman Paris Apostolopoulos Rik Glover Sascha Frinken Shipfox snapit-cypher TestingBot Vijaya Krishna Pondala Vivy
Community Champions

Inspirational members of the community

Testcontainers Community Champions actively contribute to the growth and betterment of the Testcontainers community. They are passionate about Testcontainer, and use their knowledge and skills to help others succeed.
Meet our Community Champions
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.