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: about 2 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 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-03T07:23:17.000Z (3 months ago)
- Last Synced: 2025-03-30T07:01:50.180Z (2 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: 875 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Testcontainers Extensions
[](https://openjdk.org/projects/jdk/17/)
[](https://maven-badges.herokuapp.com/maven-central/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)## 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());
}
}
```