https://github.com/goodforgod/testcontainers-extensions
🧰 Testcontainers Extensions with advanced testing capabilities.
https://github.com/goodforgod/testcontainers-extensions
assertions cassandra cockroachdb extensions flyway kafka liquibase mariadb migration mockserver mysql oracle postgresql redis testcontainers
Last synced: 4 months ago
JSON representation
🧰 Testcontainers Extensions with advanced testing capabilities.
- Host: GitHub
- URL: https://github.com/goodforgod/testcontainers-extensions
- Owner: GoodforGod
- License: apache-2.0
- Created: 2023-07-10T17:05:42.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2026-03-10T11:47:45.000Z (4 months ago)
- Last Synced: 2026-03-10T18:42:51.801Z (4 months ago)
- Topics: assertions, cassandra, cockroachdb, extensions, flyway, kafka, liquibase, mariadb, migration, mockserver, mysql, oracle, postgresql, redis, testcontainers
- Language: Java
- Homepage: http://goodforgod.dev/testcontainers-extensions/
- Size: 927 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Testcontainers Extensions
[](https://openjdk.org/projects/jdk/17/)
[](https://central.sonatype.com/artifact/io.goodforgod/testcontainers-extensions-postgres)
[](https://github.com/GoodforGod/testcontainers-extensions/actions?query=workflow%3A"CI+Master"++)
[](https://sonarcloud.io/dashboard?id=GoodforGod_testcontainers-extensions)
[](https://sonarcloud.io/dashboard?id=GoodforGod_testcontainers-extensions)
[](https://sonarcloud.io/dashboard?id=GoodforGod_testcontainers-extensions)
Testcontainers Extensions with advanced testing capabilities.
Makes testing & asserts with Testcontainers even easier.
## Featured extensions
- [Postgres](postgres)
- [Kafka](kafka)
- [Oracle](oracle)
- [MariaDB](mariadb)
- [MySQL](mysql)
- [Cockroachdb](cockroachdb)
- [Cassandra](cassandra)
- [Redis](redis)
- [MockServer](mockserver)
- [Minio](minio)
- [Clickhouse](clickhouse)
- [Redpanda](redpanda)
- [Scylla](scylla)
- [NATS](nats)
## Usage
Here is an example of [Kafka Extension](kafka) where KafkaContainer is started in `PER_RUN` mode with topic reset per method:
```java
@TestcontainersKafka(mode = ContainerMode.PER_RUN,
topics = @Topics(value = "my-topic-name", reset = Topics.Mode.PER_METHOD))
class ExampleTests {
@ConnectionKafka
private KafkaConnection kafkaConnection;
@Test
void test() {
var consumer = kafkaConnection.subscribe("my-topic-name");
kafkaConnection.send("my-topic-name", Event.ofValue("event1"), Event.ofValue("event2"));
consumer.assertReceivedAtLeast(2, Duration.ofSeconds(5));
}
}
```
Here is an example of [Postgres Extension](postgres) where PostgresContainer is started `PER_RUN` mode and migrations are applied per method:
```java
@TestcontainersPostgreSQL(mode = ContainerMode.PER_RUN,
migration = @Migration(
engine = Migration.Engines.FLYWAY,
apply = Migration.Mode.PER_METHOD,
drop = Migration.Mode.PER_METHOD))
class ExampleTests {
@ConnectionPostgreSQL
private JdbcConnection postgresConnection;
@Test
void test() {
postgresConnection.execute("INSERT INTO users VALUES(1);");
var usersFound = postgresConnection.queryMany("SELECT * FROM users;", r -> r.getInt(1));
assertEquals(1, usersFound.size());
}
}
```
## Testcontainers compatibility
- Version 0.13+ - build on top of Testcontainers [1.21.3](https://mvnrepository.com/artifact/org.testcontainers/testcontainers/1.21.3)
- Version 0.12+ - build on top of Testcontainers [1.19.8](https://mvnrepository.com/artifact/org.testcontainers/testcontainers/1.19.8)