https://github.com/h1alexbel/cdit
A Collection of Pre-Configured Docker Containers for your Integration Tests
https://github.com/h1alexbel/cdit
docker integration-testing java testcontainers
Last synced: about 1 year ago
JSON representation
A Collection of Pre-Configured Docker Containers for your Integration Tests
- Host: GitHub
- URL: https://github.com/h1alexbel/cdit
- Owner: h1alexbel
- License: mit
- Archived: true
- Created: 2023-12-06T10:29:59.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-05T23:20:59.000Z (about 2 years ago)
- Last Synced: 2025-03-04T18:45:59.185Z (about 1 year ago)
- Topics: docker, integration-testing, java, testcontainers
- Language: Java
- Homepage:
- Size: 73.2 KB
- Stars: 6
- Watchers: 4
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README

[](https://self-xdsd.com/p/h1alexbel/cdit?provider=github)
[](https://www.elegantobjects.org)
[](https://www.rultor.com/p/h1alexbel/cdit)
[](https://www.jetbrains.com/idea/)
[](https://github.com/h1alexbel/cdit/actions/workflows/mvn.yml)
[](https://search.maven.org/artifact/io.github.h1alexbel/cdit)
[](https://javadoc.io/doc/io.github.h1alexbel/cdit)
[](https://codecov.io/gh/h1alexbel/cdit)
[](https://hitsofcode.com/view/github/h1alexbel/cdit)
[](https://github.com/h1alexbel/cdit)
[](http://www.0pdd.com/p?name=h1alexbel/cdit)
[](https://github.com/h1alexbel/cdit/blob/master/LICENSE.txt)
Project architect: [@h1alexbel](https://github.com/h1alexbel)
A Collection of Pre-Configured Docker Containers for your Integration Tests.
**Motivation**. We are not happy with configuring Testcontainers again and again the same way,
so we create a "hosted" home and fill it with common pre-configured Docker containers for integration testing.
**Principles**. These are the [design principles](https://www.elegantobjects.org/#principles) behind cdit.
**How to use**. All you need is this (get the latest version [here](https://search.maven.org/artifact/io.github.h1alexbel/cdit)):
Maven:
```xml
io.github.h1alexbel
cdit
test
```
Gradle:
```groovy
dependencies {
testCompile 'io.github.h1alexbel:cdit:'
}
```
## Running Containers
To create Docker container, for instance [PostgreSQL](https://hub.docker.com/_/postgres), you can use
```java
import org.cdit.containers.Postgres;
import org.cdit.containers.Env;
new Postgres(
"latest",
new Env("POSTGRES_USER", "user"),
new Env("POSTGRES_PASSWORD", "AAAA...CCCC")
).run();
```
Now Docker container is up and running.
## Creating Custom Containers
If you want to create your own container, you can extend [ContainerEnvelope](https://github.com/h1alexbel/cdit/blob/master/src/main/java/org/cdit/ContainerEnvelope.java)
this way
```java
import org.cdit.ContainerEnvelope;
public final class MyPrivateContainer extends ContainerEnvelope {
public MyPrivateContainer(final String tag, final Env... vars) {
super("ecr.io/myprivate:%s".formatted(tag), vars);
}
}
```
now, you can run it
```java
new MyPrivateContainer("0.0.1", new Env("test", "true")).run();
```
If you need more flexible configuration, it can be achieved by implementing [Container](https://github.com/h1alexbel/cdit/blob/master/src/main/java/org/cdit/Container.java)
```java
import org.cdit.Container;
import org.testcontainers.containers.GenericContainer;
public final class MyPrivateContainer implements Container {
@Override
public GenericContainer> run() {
// your code
}
}
```
## How to Contribute
Fork repository, make changes, send us a [pull request](https://www.yegor256.com/2014/04/15/github-guidelines.html).
We will review your changes and apply them to the `master` branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run full Maven build:
```bash
$ mvn clean install -Pinvoker
```
You will need Maven 3.8.7+ Java 17+, and Docker.
Our [rultor image](https://github.com/eo-cqrs/eo-kafka-rultor-image) for CI/CD.