首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >黄瓜-Jvm重试失败方案

黄瓜-Jvm重试失败方案
EN

Stack Overflow用户
提问于 2014-05-15 10:05:29
回答 1查看 1.9K关注 0票数 0

我想自动重试失败的测试,以提高测试的可靠性,类似于在Junit中找到的TestRule,我希望能够灵活地在测试周围插入逻辑,这样我就可以实现一个retry循环:

  • 我使用的是Cucumber-JVM,需要一个涉及JavaGradle的解决方案。
  • 我通过Gradle javaexec尝试了以下黄瓜选项: //-格式漂亮--格式重新运行--输出tmp/reerun.txt //-格式重新运行--输出C:\Desktop\failed.txt

目前,我正在通过RunCukesTest.java尝试这个过程。

代码语言:javascript
复制
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 {
}
EN

回答 1

Stack Overflow用户

发布于 2014-09-24 20:40:02

德维斯·苏莱曼的回答是不可能的:

在环顾四周,尝试了几件事之后,我终于找到了一个快速而又肮脏的解决方案。这是我的解决方案:

代码语言:javascript
复制
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 cucumberRerun
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23675126

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档