【问题标题】:Getting RSpec to report intermediate failures让 RSpec 报告中间故障
【发布时间】:2011-08-30 23:36:54
【问题描述】:

有没有办法让 RSpec 在发生故障时报告故障,而不是一长串绿/红点? 我正在运行 RSpec 2.5.0。

【问题讨论】:

    标签: ruby testing rspec


    【解决方案1】:

    RSpec 支持多种输出格式,由--format 选项指定。默认值为“progress”,即您看到的一串点。如果您更改为更详细的格式,您将在运行时看到红色/绿色的测试名称,但在最后打印的摘要之前您仍然看不到失败的原因。

    运行rspec --help 的其他格式选项是:

    -f, --format FORMATTER           Choose a formatter
                                       [p]rogress (default - dots)
                                       [d]ocumentation (group and example names)
                                       [h]tml
                                       [t]extmate
                                       custom formatter class name
    

    除了在命令行中指定格式,你还可以在你的主目录下放一个“.rspec”文件来指定默认选项。

    【讨论】:

      【解决方案2】:

      使用different format,例如--format documentation

      您可以将它作为参数传递给 CLI。

      $ rspec spec/ --format documentation
      

      【讨论】:

        【解决方案3】:

        您可以看看那里的不同格式化程序。我猜你要找的是FailingExamplesFormatter,就像这样运行:

        spec spec --require spec/runner/formatter/failing_examples_formatter.rb --formatter FailingExamplesFormatter
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-04-09
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-06-22
          • 2015-09-08
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多