【问题标题】:Cucumber-Jvm retry failed ScenariosCucumber-Jvm 重试失败场景
【发布时间】:2014-09-26 00:46:24
【问题描述】:

我想自动重试失败的测试,以提高我的测试的可靠性,类似于 Junit 中的 TestRule 我想灵活地在测试周围插入逻辑,所以我可以实现重试循环:

  • 我正在使用 Cucumber-JVM,需要一个涉及 JavaGradle 的解决方案

  • 我已经通过 Gradle javaexec 尝试了以下黄瓜选项:

    //--format pretty --format rerun --out tmp/rerun.txt

    //--format rerun --out C:\Desktop\failed.txt

目前我正在通过 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 {
}

【问题讨论】:

    标签: java cucumber cucumber-jvm


    【解决方案1】:

    将 Dervis suleyman 的答案排除在外:

    环顾四周并尝试了一些事情后,我最终决定进行快速而肮脏的修复。这是我的解决方案:

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-23
      • 1970-01-01
      相关资源
      最近更新 更多