And*_*lov 57
使用重新运行格式化程序运行Cucumber:
cucumber -f rerun --out rerun.txt
Run Code Online (Sandbox Code Playgroud)
它会将所有失败方案的位置输出到此文件.
然后你可以使用重新运行它们
cucumber @rerun.txt
Run Code Online (Sandbox Code Playgroud)
这是我简单整洁的解决方案。
步骤1:使用编写您下面提到的黄瓜Java文件rerun:target/rerun.txt。黄瓜将失败的方案行号写入rerun.txt如下所示。
features/MyScenaios.feature:25
features/MyScenaios.feature:45
Run Code Online (Sandbox Code Playgroud)
稍后,我们可以在步骤2中使用该文件。将该文件命名为MyScenarioTests.java。这是运行带标记的方案的主文件。如果您的方案没有通过测试,请在目标目录下MyScenarioTests.java编写/标记它们rerun.txt。
@RunWith(Cucumber.class)
@CucumberOptions(
monochrome = true,
features = "classpath:features",
plugin = {"pretty", "html:target/cucumber-reports",
"json:target/cucumber.json",
"rerun:target/rerun.txt"} //Creates a text file with failed scenarios
,tags = "@mytag"
)
public class MyScenarioTests {
}
Run Code Online (Sandbox Code Playgroud)
步骤2:创建另一个方案文件,如下所示。可以这样说FailedScenarios.java。每当您发现任何失败的方案时,都运行此文件。该文件将target/rerun.txt用作运行方案的输入。
@RunWith(Cucumber.class)
@CucumberOptions(
monochrome = true,
features = "@target/rerun.txt", //Cucumber picks the failed scenarios from this file
format = {"pretty", "html:target/site/cucumber-pretty",
"json:target/cucumber.json"}
)
public class FailedScenarios {
}
Run Code Online (Sandbox Code Playgroud)
每当您发现任何失败的方案时,请在步骤2中运行文件
| 归档时间: |
|
| 查看次数: |
31401 次 |
| 最近记录: |