Getting RSpec to report intermediate failures

梦想与她 提交于 2020-01-01 18:17:06

问题


Is there a way to get RSpec to report failures as they occur, instead of the long list of green/red dots? I'm running RSpec 2.5.0.


回答1:


RSpec supports multiple output formats, specified with the --format option. The default is "progress", the string of dots you're seeing. If you change to a more verbose format, you'll see the name of the test in red/green as you run, but you still won't see what the failure was until the summary that's printed at the end.

The other format options, from running rspec --help are:

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

In addition to specifying format on the command line, you can put a ".rspec" file in your home directory to specify default options.




回答2:


Use a different format, such as --format documentation.

You can pass it as argument to the CLI.

$ rspec spec/ --format documentation



回答3:


You may take a look at the different formatters out there. I guess the one you are looking for is FailingExamplesFormatter to be run just like this:

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


来源:https://stackoverflow.com/questions/7250972/getting-rspec-to-report-intermediate-failures

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!