我的自动化项目中有两个运行程序,如下所示:
主要运行程序 - 执行所有
@ui-test
标记的测试用例,如果场景失败target/rerun.txt
将填充场景位置(例如features/Dummy.feature:22
):@RunWith(Cucumber.class) @CucumberOptions( features = "classpath:features", plugin = {"pretty", "html:target/cucumber-html-report", "json:target/cucumber.json", "rerun:target/rerun.txt"}, tags = {"@ui-test", "~@ignore"} ) public class RunCukesTest { }
辅助运行程序 - 重新执行
target/rerun.txt
中的场景:@RunWith(Cucumber.class) @CucumberOptions( features = "@target/rerun.txt", plugin = {"pretty", "html:target/cucumber-html-report-rerun", "json:target/cucumber_rerun.json"} ) public class ReRunFailedCukesTest { }
执行时会创建两个结果 json 文件:
cucumber .json
cucumber_rerun.json
Jenkins 将通过 Cucumber-JVM Reports
插件收集结果并创建合并报告。
问题是,即使第二次运行时所有 target/rerun.txt
测试都通过了,由于 cucumber.json
的原因,报告状态仍将保持失败状态。
有没有办法(设置Cucumber-JVM Reports
插件或修改上面显示的运行程序)用cucumber_rerun的结果覆盖
并仅发布修改后的 cucumber.json
.jsoncucumber.json
?
另一个子关键字:maven
、java
、cucumber-java8
、cucumber-junit
、junit
最佳答案
我遇到了与你类似的问题,不过,我使用了单个运行程序,直接处理了 testNG 的重新运行(重新运行是我从 JUnit 切换到 TestNG 的原因之一),结果我得到了我的 json 报告中的测试数量增加。 我的解决方案是事后清理 json 文件,尽管 Jenkins 知道失败的测试,但它不会将构建标记为失败或不稳定。 在您的特定情况下,您可以尝试以某种方式匹配 rerun.json 中的测试并将它们从常规 json 报告中排除。 为了解析 json,我建议使用 Jackson FasterXML
关于jenkins - 将多个 json 结果合并到一份更新的 Cucumber-JVM 报告中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39742420/