【问题标题】:Is it possible to generate cucumber html reports with only scenario titles with out steps是否可以生成只有场景标题而没有步骤的黄瓜 html 报告
【发布时间】:2013-08-16 10:41:52
【问题描述】:

是否可以生成只有场景标题而没有步骤的黄瓜 html 报告?

我希望通过电子邮件生成 html 报告,但我希望生成的报告只包含标题的所有场景,这样我的报告不会很大并且很容易知道哪些场景失败了。

我相信有人可能对此有解决方案。谁能分享这个或告诉我如何完成它。

提前致谢

【问题讨论】:

    标签: cucumber


    【解决方案1】:

    您需要构建一个自定义格式化程序。 Cucumber Wiki 有一些关于这样做的细节。

    要隐藏这些步骤,您可以创建一个自定义格式化程序来覆盖 Html 格式化程序的 before_step_resultbuild_step 方法。

    如果您的支持文件夹创建一个 .rb 文件:

    require 'cucumber/formatter/html'
    
    module Cucumber
      module Formatter
        class HtmlStepless < Html
          def before_step_result(step_result)
            #TODO: What is this used for?
            @step_match = step_result.step_match
            @hide_this_step = true
            if step_result.exception
              if @exceptions.include?(step_result.exception)
                @hide_this_step = true
                return
              end
              @exceptions << step_result.exception
            end
            if step_result.status != :failed && @in_background ^ step_result.background
              @hide_this_step = true
              return
            end
            @status = step_result.status
            return if @hide_this_step
            set_scenario_color(step_result.status)
            @builder << "<li id='#{@step_id}' class='step #{step_result.status}'>"
          end
    
          def build_step(keyword, step_match, status)
            # Do nothing
          end
    
        end
      end
    end
    

    当你运行 Cucumber 时,告诉它使用自定义格式化程序:

    cucumber -f Cucumber::Formatter::HtmlStepless -o output.htm
    

    【讨论】:

    • 谢谢贾斯汀,我会试试这个解决方案。非常感谢
    猜你喜欢
    • 1970-01-01
    • 2018-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-13
    相关资源
    最近更新 更多