I have several tasks of Type Test that I have added to my build, like this:
// dynamically build up a testng task for every testng suite found.
// for example testng-unit-test-suite will become a task called runTestSuiteUnit
def testngSuiteTree = fileTree('test/resources/conf/testng').include('testng-*-test-suite.xml')
testngSuiteTree.each { file ->
def matcher = file.name =~ /testng-(.*)-test-suite.xml/
def suiteName = matcher[0][1]
def relativePath = ("${file.path}" =~ /${projectDir}\//).replaceFirst("")
task "runTestSuite${suiteName.capitalize()}"(type: Test) {
// need to get relative path
useTestNG() {
suites "${relativePath}"
}
}
}
This is working great. The problem is that if my test task succeeds, the task will get marked as ‘UP-TO-DATE’ on subsequent runs and skipped.
Are there suggests on how I can change this behavior such that my Test task will always run, even if a previous build succeeded and nothing changes?
There might be one problem with the above. It assumes that the intTest tasks are already created. If you do the following, you specify a configuration rule that is either applied to the existing tasks of tasks that will be added in the future:
I made not changes to my build.gradle and only did as Hans has said on the command line. It worked a charm. I was going insane trying to get my jacoco report generated…the above forced my tests to be run, so that the .exec was generated, so that my jacocoTestReport would run.