【问题标题】:Generate HTML file from rspec从 rspec 生成 HTML 文件
【发布时间】:2010-12-21 06:06:08
【问题描述】:

如何从 rspec 生成 HTML 报告?

【问题讨论】:

    标签: rspec


    【解决方案1】:

    在前面的答案的基础上,它非常简单:

    rspec /directory/containing/specs/** --format h > output.html
    

    我使用以下路径规范/** 从我的 rails 应用程序的根目录运行它。 我希望这会有所帮助。如果你有非“_spec.rb”文件,你可能需要修改路径参数。

    【讨论】:

    • 我使用 "> out.html" 而不是 "--out out.html" 的问题是 rspec 命令也回显到 HTML 文件中,在 <!DOCTYPE html>
    【解决方案2】:

    我们可以添加

    --format html
    --out rspec_results.html
    

    到.rspec

    所以 rspec 会将结果写入 rspec_results.html

    https://coderwall.com/p/gfmeuw

    【讨论】:

      【解决方案3】:

      RSpec 有一个命令行选项来生成 html 格式的输出:

      rspec <path_to_spec_file> --format html
      

      【讨论】:

      • 基本上我的问题是我想在单个 html 文件中生成所有控制器的所有测试用例的 html 报告。这可以生成报告吗????
      【解决方案4】:

      来自https://www.relishapp.com/rspec/rspec-core/docs/command-line/format-option

      场景:多种格式

      当我运行rspec example_spec.rb --format progress --format documentation --out rspec.txt

      那么输出应该包含“.F*”

      并且文件“rspec.txt”应该包含:

      something does something that passes does something that fails (FAILED - 1) does something that is pending (PENDING: No reason given)
      

      【讨论】:

        【解决方案5】:

        使用-o--out 选项指定输出文件。

        使用-f--format 选项指定格式

        rspec spec/* --format html --out report.html
        

        【讨论】:

          【解决方案6】:

          对于那些使用 Jenkins 的人,请查看 XUNIT 插件

          https://wiki.jenkins-ci.org/display/JENKINS/xUnit+Plugin

          【讨论】:

            【解决方案7】:

            您可以使用rspec_html_formatter gem 生成漂亮的 RSpec html 报告。实施见https://github.com/kingsleyh/rspec_reports_formatter

            rspec -f RspecHtmlFormatter spec

            【讨论】:

              猜你喜欢
              • 2011-11-29
              • 2011-10-05
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2014-09-29
              • 2012-05-20
              • 1970-01-01
              • 2017-12-12
              相关资源
              最近更新 更多