在我的gradle文件中,我有3个Test
类型的任务:
/**
* This is a test block called 'sampleA' to run testng tests.
*/
task sampleA(type: Test) {
include "**/Helloworld4a*"
}
/**
* This is a test block called 'sampleB' to run testng tests.
*/
task sampleB(type: Test) {
include "**/Helloworld4b*"
}
/**
* This is a test block called 'sampleC' to run testng tests.
* This block depends on sampleB block.
*/
task sampleC(type: Test, dependsOn: sampleB) {
include "**/Helloworld4*"
exclude "**/Helloworld4a*"
exclude "**/Helloworld4b*"
}
现在我创建了一个插件,我在其中添加了一个TaskExecutionListener。在TaskExecutionListener中,我只为每个任务创建一个文件,而不管任务是否成功执行。
当我运行gradle sampleA sampleB sampleC
时,它只运行sampleA
,这是预期的(因为任务失败)
但是当我使用--continue
选项时,结果是一样的。如果不添加监听器,我会看到sampleA
和sampleB
都在运行。
这是我的听众课程
class TestInfraTaskListener implements TaskExecutionListener {
/**
* Generate the test results for the EMTestNGTest types
*/
public void afterExecute(Task task, TaskState state) {
if(task instanceof Test) {
/* If testng test type, then generate results. */
def resultHandler = new TestResultsHandler(task, state)
/* Generate individual result files */
resultHandler.generateResultFiles()
resultHandler.uploadToJira()
state.rethrowFailure()
}
}
}
当我设置ignoreFailure = true
时,所有3个任务都会运行。我在这里做错了什么我只想使用sampleA
选项运行sampleB
和--continue
。
My Gradle版本为1.11(我无权升级)
答案 0 :(得分:0)
好的,终于让它符合以下规则:
ignoreFailures = true
Test
或state.rethrowFailure()
(任务是否成功)