I have some integration tests written with Spring Boot and want to run them on demand. Not while doing ./gradlew build but I want to run them with ./gradlew integrationTest.
I want to run this integrationTest task inside Docker container
I have put the integration tests code in the folder src/integrationtest and created the integration-test.gradle file as below: [I'm using Gradle 5.2]
sourceSets {
integrationTest {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
resources.srcDir file('src/integrationtest/resources')
}
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
integrationTestAnnotationProcessor.extendsFrom testAnnotationProcessor
}
idea {
module {
testSourceDirs += sourceSets.integrationTest.java.srcDirs
testResourceDirs += sourceSets.integrationTest.resources.srcDirs
scopes.TEST.plus += [configurations.integrationTestCompile]
}
}
task integrationTest(type: Test) {
description = 'Runs the integration tests.'
group = 'verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
shouldRunAfter test
}
check.dependsOn -= integrationTest
And also applied this on my build.gradle apply from: 'gradle/integration-test.gradle'
I've created this docker file and named it Dockerfile.it:
FROM openjdk:8u191-jdk-alpine as build
ENV APP_WORKSPACE=/workspace/app/
WORKDIR $APP_WORKSPACE
COPY gradlew .
COPY gradle gradle
COPY build.gradle settings.gradle $APP_WORKSPACE
COPY lombok.config lombok.config
COPY src src
ENV GRADLE_OPTS -Dorg.gradle.daemon=false
ENV AWS_ACCESS_KEY_ID="aws-access-key-id"
ENV AWS_SECRET_ACCESS_KEY="aws-secret-access-key"
ENV AWS_REGION="us-west-2"
ENTRYPOINT ["./gradlew", "integrationTest"]
When I run the command ./gradlew integrationTest directly on my terminal in the project folder, everything works just fine, but when I build the Docker Image and run the Docker container from that image, the actual output is:
Downloading https://services.gradle.org/distributions/gradle-5.2-bin.zip
....................................................................................................................................................................................
Unzipping /root/.gradle/wrapper/dists/gradle-5.2-bin/2di47o96ob6dhysr22jutthm6/gradle-5.2-bin.zip to /root/.gradle/wrapper/dists/gradle-5.2-bin/2di47o96ob6dhysr22jutthm6
Set executable permissions for: /root/.gradle/wrapper/dists/gradle-5.2-bin/2di47o96ob6dhysr22jutthm6/gradle-5.2/bin/gradle
> Task :compileJava
> Task :processResources
> Task :classes
> Task :compileIntegrationTestJava NO-SOURCE
> Task :processIntegrationTestResources NO-SOURCE
> Task :integrationTestClasses UP-TO-DATE
> Task :integrationTest NO-SOURCE
BUILD SUCCESSFUL in 3m 54s
2 actionable tasks: 2 executed
These lines are my problem:
Task :compileIntegrationTestJava NO-SOURCE
Task :processIntegrationTestResources NO-SOURCE
Task :integrationTestClasses UP-TO-DATE
Task :integrationTest NO-SOURCE
What am I missing or doing incorrectly?