【发布时间】:2020-06-11 08:40:13
【问题描述】:
我有一个自定义任务定义来运行具有每个测试特殊设置的特定测试文件。 我的任务定义如下所示:
task retryTest(type: Test) {
description = 'Dummy Retry Test'
group = 'verification'
maxHeapSize = '2048m'
include '**/*SpecificIntegrationTest.class'
}
现在,此设置中的一些测试不稳定,我尝试像这样重新运行它们:
plugins {
id "org.gradle.test-retry" version "1.1.1"
}
task retryTest(type: Test) {
description = 'Dummy Retry Test'
group = 'verification'
maxHeapSize = '2048m'
include '**/*SpecificIntegrationTest.class'
test {
retry {
maxRetries = 2
}
}
}
我写了一个测试类,第一次总是失败,第二次就成功了:
public class RetryTest {
private int execCount = 0;
@Test
public void throwException() {
if (execCount == 0) {
execCount++;
throw new NotImplementedException();
}
}
}
不幸的是,测试只执行一次,整个测试套件都失败了。我可以使用https://stackoverflow.com/a/55178053/6059889中描述的自定义规则成功运行测试
有没有办法将测试重试插件与自定义任务定义一起使用?
【问题讨论】: