OSS TanbouSign in with GitHub

A Java library that starts disposable Docker containers during JUnit tests to verify integrations with realistic services

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
8,749
Primary language
Java
License
MIT
Repository last updated
Oct 5, 2026
On this page

Overview

Testcontainers for Java starts databases, message brokers, and other dependencies as Docker containers for a test and removes them afterward. It reduces manually maintained developer environments while exercising real network boundaries.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

What it verifies

JUnit integration scopes container startup and shutdown to the test lifecycle and can wait for known logs or ports. Alongside GenericContainer, dedicated modules cover common databases and services.

Sources: [1][2][3][6]

Best fit

Where it fits

It fits Java projects that continuously verify SQL dialects, connection setup, queues, and other integrations that mocks can miss. The pinned example checks output from a disposable Alpine container in JUnit.

Sources: [1][2]

Before adoption

What to check before running

The 2.0 line targets Java 17 or later and needs an available Docker-compatible runtime plus network access to obtain images. Test containers do not reproduce production capacity or availability. The LICENSE is MIT.

Sources: [3][4][5]

Official sources

  1. [1]testcontainers/testcontainers-java README at 2.0.5(2026-10-05)
  2. [2]Testcontainers for Java official documentation(2026-10-05)
  3. [3]Testcontainers for Java 2.0.5 source(2026-10-05)
  4. [4]testcontainers/testcontainers-java LICENSE at 2.0.5(2026-10-05)
  5. [5]testcontainers/testcontainers-java GitHub metadata(2026-10-05)
  6. [6]Testcontainers 2.0.5 Wait strategy API source(2026-10-05)
Supplemental curator note

It is useful when a Java team needs stronger evidence at service boundaries than mocks provide. First verify log readiness and automatic disposal with a small image, then move to the module for the actual database.

Try it in 3 steps

  1. 1

    Create a pinned JUnit project

    Requires Java 17 or later, Maven, and a running Docker-compatible runtime. Create a temporary project pinned to Testcontainers 2.0.5 and JUnit.

    demo=$(mktemp -d "${TMPDIR:-/tmp}/testcontainers-java.XXXXXX") && cd "$demo" && mkdir -p src/test/java/demo && printf '%s\n' '<project xmlns="http://maven.apache.org/POM/4.0.0"><modelVersion>4.0.0</modelVersion><groupId>demo</groupId><artifactId>container-test</artifactId><version>1</version>' '<properties><maven.compiler.release>17</maven.compiler.release></properties>' '<dependencies><dependency><groupId>org.testcontainers</groupId><artifactId>testcontainers</artifactId><version>2.0.5</version><scope>test</scope></dependency><dependency><groupId>org.testcontainers</groupId><artifactId>testcontainers-junit-jupiter</artifactId><version>2.0.5</version><scope>test</scope></dependency><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter</artifactId><version>5.11.4</version><scope>test</scope></dependency></dependencies>' '<build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.14.1</version></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>3.5.4</version></plugin></plugins></build></project>' > pom.xml
  2. 2

    Write a disposable-container test

    Write a JUnit test that starts Alpine 3.22 for the test lifecycle and waits at most 30 seconds for its ready log.

    printf '%s\n' 'package demo;' 'import org.junit.jupiter.api.Test;' 'import org.testcontainers.containers.GenericContainer;' 'import org.testcontainers.junit.jupiter.Container;' 'import org.testcontainers.junit.jupiter.Testcontainers;' 'import org.testcontainers.containers.wait.strategy.Wait;' 'import java.time.Duration;' 'import org.testcontainers.utility.DockerImageName;' 'import static org.junit.jupiter.api.Assertions.assertTrue;' '@Testcontainers class ContainerTest {' ' @Container static GenericContainer<?> alpine = new GenericContainer<>(DockerImageName.parse("alpine:3.22")).withCommand("sh","-c","echo ready; sleep 30").waitingFor(Wait.forLogMessage(".*ready.*\n",1).withStartupTimeout(Duration.ofSeconds(30)));' ' @Test void capturesContainerOutput() { assertTrue(alpine.getLogs().contains("ready")); }' '}' > src/test/java/demo/ContainerTest.java
  3. 3

    Verify container output

    Run the JUnit test and require ready in the container log. Testcontainers manages disposal at the end of the test.

    mvn -q -Dtest=ContainerTest test
Check the official README

Growth

Growth trends · Last 30 days

8,749 Stars

Trend data is still being collected.

Development activity

Last 90 days · weekly

Commits (last 30 days)
6
Open PRs
213

Development activity is still being collected.

Built with

Categories and tags

Categories

GitHub data

GitHub dataView detailed GitHub data

GitHub Topics

  • java
  • docker
  • docker-compose
  • junit
  • test-automation
  • jvm
  • testing
  • hacktoberfest
  • integration-testing
Stars
8,749
Forks
1,936
Watchers
132
Open issues
416
Contributors
441
Owner type
Organization
Primary language
Java
License
MIT
Repository last updated
Oct 5, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?