'Gradle custom task to run tests in loop
My challenge is to run my custom tasks (E2E tests) step by step (sequentially) I have a few task like (yes, they are redundant)
task test1(type: Test) {
group = E2E //var
systemProperty "spring.profiles.active", System.properties['spring.profiles.active']
testLogging.showStandardStreams = true
useJUnitPlatform {
excludeTags 'regress'
}
include 'com/tests/lib/**'
maxParallelForks = 1
}
Other task i wish to run:
task test2(type: Test) {
group = E2E //var
systemProperty "spring.profiles.active", System.properties['spring.profiles.active']
testLogging.showStandardStreams = true
useJUnitPlatform {
excludeTags 'regress'
}
include 'com/tests/core/**'
maxParallelForks = 1
}
How can i run them sequentially?
I was thinking about having one task which run them in a loop like:
task runTests {
tasks.each {
task ->
if (task.group == E2E) {
println("Running E2E test: " + task.name)
dependsOn(task)
println(task.name + " finished. " + task.getDidWork())
}
}
}
However it seems gradle first read all of them and add it in its queue and then execute. Gradle output:
> Configure project :intests
Running E2E test: test1
test1 finished. false
Running E2E test: test2
test2 finished. false
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
