gpt4 book ai didi

testing - 有没有办法让 cucumber 在进入下一个场景之前再次尝试一个场景

转载 作者:行者123 更新时间:2023-11-28 20:23:51 24 4
gpt4 key购买 nike

我正在努力清理我们工作中的功能套件,我想知道是否有办法让 Cucumber 重复一个场景,看看是否通过,然后再进入功能中的下一个场景? Phantom 是我的 headless webkit 浏览器 poltergeist 是我的司机。

基本上我们的构建一直失败,因为盒子被所有测试淹没,并且在场景中页面将没有足够的时间来呈现我们正在尝试测试的任何内容。因此,这会产生误报。我不知道有什么方法可以预测什么测试会挂断构建。

在每个场景之后都有一个钩子(Hook)(一个想法)会很好。如果场景通过,那么很好地打印该场景的结果并继续。但是,如果场景失败,请尝试再次运行它以确保它不是构建变得头晕。然后,也只有在那时,您才能打印该场景的结果并继续进行下一个测试。

有人知道如何实现吗?

我在想类似的事情

 After do |scenario|
if scenario.failed?
result = scenario.run_again # I just made this function up I know for a fact this doesn't actually exist (see http://cukes.info/api/cucumber/ruby/yardoc/Cucumber/Ast/Scenario.html)
if !result
Cucumber.wants_to_quit = true
end
end
end

我看到的最初解决方案是:How to rerun the failed scenarios using Cucumber?

这很好,但我需要确保

 cucumber @rerun.txt

如果测试通过,实际上会更正报告。喜欢

 cucumber @rerun.txt --format junit --out foo.xml

其中 foo.xml 是 junit 报告,最初表示功能 1、2 和 5 通过,而 3 和 4 失败,但现在会说 1、2、3、4 和 5 即使 rerun.txt 也通过只说重新运行 3 和 4。

最佳答案

我广泛使用 rerun,是的,它确实将正确的特征输出到 rerun.txt 文件中。我有一个 cucumber.yml 文件,它定义了一堆“配置文件”。注意重新运行配置文件:

    <%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
%>

<% standart_opts = "--format html --out report.html --format rerun --out rerun.txt --no-source --format pretty --require features --tags ~@wip" %>
default: <%= standart_opts %> --no-source --format pretty --require features


rerun: <%= rerun_opts %> --format junit --out junit_format_rerun --format html --out rerun.html --format rerun --out rerun.txt --no-source --require features

core: <%= standart_opts %> --tags @core
jenkins: <%= standart_opts %> --tags @jenkins

所以这里发生的是我运​​行 cucumber。在初始运行期间,它会将所有失败的场景扔到 rerun.txt 文件中。然后,我将使用以下命令仅重新运行失败的测试:

cucumber -p rerun

唯一的缺点是它需要一个额外的命令(当然你可以自动执行)并且如果你有它们的话它会弄乱测试指标。

关于testing - 有没有办法让 cucumber 在进入下一个场景之前再次尝试一个场景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21487477/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com