1

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

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

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

提前致谢

4

1 回答 1

2

您需要构建一个自定义格式化程序。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
于 2013-08-16T13:02:49.953 回答