我想自动重试失败的测试,以提高测试的可靠性,类似于在Junit中找到的TestRule,我希望能够灵活地在测试周围插入逻辑,这样我就可以实现一个retry循环:
目前,我正在通过RunCukesTest.java尝试这个过程。
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
/**
* String dotcucumber
boolean dryRun
String[] features
String[] format
String[] glue
boolean monochrome
String[] name
Specify a patternfilter for features or scenarios
SnippetType snippets
boolean strict
String[] tags
*
*/
@RunWith(Cucumber.class)
@CucumberOptions(monochrome = true)
public class RunCukesTest {
}发布于 2014-09-24 20:40:02
德维斯·苏莱曼的回答是不可能的:
在环顾四周,尝试了几件事之后,我终于找到了一个快速而又肮脏的解决方案。这是我的解决方案:
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "cucumber.api.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['-f', 'rerun:rerun.txt','--glue', 'org.test.cucumber', 'src/test/resources']
}
}
}
task cucumberRerun() {
dependsOn assemble, compileTestJava
doLast {
def file1 = new File('rerun.txt')
for (int i=0;i<file1.getText().split(" ").length;i++) {
println file1.getText().split(" ")[i]
try {
javaexec {
main = "cucumber.api.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['-f','html:target'+i,'--glue', 'org.test.cucumber', 'src/test/resources/'+file1.getText().split(" ")[i]]
}
} catch (Exception e) {
}
}
}
}
cucumber.finalizedBy cucumberRerunhttps://stackoverflow.com/questions/23675126
复制相似问题