Gradle integration test task : How to run one test class with a specific yaml file

(worryNerd) #1

For my integration test task I need to modify that. For one test class I want to run it against the applicatio.yaml file while for other’s I want to run against the test-application.yaml. How can I do that?

This is the integration task in build.gradle :

task integrationTest(type: Test, dependsOn: ‘createConfig’) {
description = 'Runs Integration tests.'
group = 'Verification’
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
testLogging {
events ‘passed’, ‘skipped’, 'failed’
showExceptions true
exceptionFormat 'full’
showCauses true
showStackTraces true
outputs.upToDateWhen { false }
mustRunAfter test
systemProperty “spring.config.location”, “${projectDir}/build/etc/config/test-application.yaml”

Steps taken so far but did not success :

I added the if condition like this :

def fileName = fileTree(dir: “/source/”)
if (fileName.matching { include ‘TestIT.*’ }) {
systemProperty “spring.config.location”,
} else {
systemProperty “spring.config.location”,

With the above , the config was not getting over written based on the condition. IS there any way of solving this problem?

(worryNerd) #2

Any pointers here. Thanks