SgtSilvio / gradle-oci-junit-jupiter

Integration of gradle-oci and junit-jupiter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integration of gradle-oci and junit-jupiter

Maven Central javadoc GitHub

How to Use

Add the Dependency

Add the following to your build.gradle(.kts):

repositories {
    mavenCentral()
}

dependencies {
    testImplementation("io.github.sgtsilvio:gradle-oci-junit-jupiter:0.1.0")
}

Use gradle-oci

Example configuration in build.gradle(.kts):

plugins {
    id("io.github.sgtsilvio.gradle.oci")
}

oci {
    imageDependencies.forTest(tasks.test) {
        default("example/example:123")
    }
}

Configure Docker on MacOS / Windows

On MacOS and Windows host.docker.internal needs to be configured as an insecure registry in the Docker daemon configuration. Usually. host.docker.internal resolves to the address 192.168.65.254.

{
  "insecure-registries": [
    "192.168.65.254/32"
  ]
}

Start a TestContainer in Your JUnit Test

Example in Java:

class ContainerTest {
    @Test
    void testOnce() {
        final GenericContainer<?> container = new GenericContainer(OciImages.getImageName("example/example:123"));
        container.start();
        ...
    }
}

About

Integration of gradle-oci and junit-jupiter

License:Apache License 2.0


Languages

Language:Kotlin 100.0%