Skip to content
Spin up docker containers for integration tests.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper
src
.gitignore
LICENSE.txt
README.md
build.gradle
gradlew
gradlew.bat
settings.gradle

README.md

This plugin allows you to start up docker containers for testing.

Configure the plugin and test annotations

plugins {
    id "io.advantageous.docker-test" version "0.1.2"
}
...

//For docker test annotations
dependencies {
    testCompile 'io.advantageous.gradle:docker-test-plugin:0.1.0'
}

//Exclude docker tests as unit tests
test {
    useJUnit {
        excludeCategories 'io.advantageous.test.DockerTest'
    }
}

Configure your test containers in your build

testDockerContainers {
    postgresql {
        publishAll true
        containerName "postgresql"
        env (name:"PGSQL_ROLE_1_USERNAME", value:"docker")
        env ("PGSQL_ROLE_1_PASSWORD":"docker", "PGSQL_DB_1_NAME":"mydb")
        portMapping(container: 5432, host: 5432)
        image "tozd/postgresql:9.5"
        waitAfterRun 20
    }

    
    cassandra {
        publishAll true
        containerName "cassandra"
        portMapping(container: 9042, host: 9042)
        image "cassandra:2.2.5"
        waitAfterRun 20
    }
}

Start test containers for testing in your IDE

$ gradle startTestDocker

Mark your test classes that need these containers

import io.advantageous.test.DockerTest

@Category(DockerTest::class)
public class FanCountBackFillJobTest {
    @Test
    fun doRun() {

To run tests that need docker use dockerTest

$ gradle clean dockerTest build  
You can’t perform that action at this time.