Rspec: How to capture the examples, Failures and pending Count

不想你离开。 提交于 2020-01-07 04:41:09

问题


Well i am trying to achieve one thing. Something fancy but worth trying..

When i run bundle exec rspec spec/

My test cases pass and i get

Finished in 5.12 seconds
38 examples, 0 failures, 1 pending

I want to use the MAC OS say command (Read here about it). Which will say after the test suite has completed, that you have 38 examples, 0 failures and 1 pending example.

eg command

say you have example_count examples, failures_count failures and pending_count pending examples

The requirement is, I need to capture Examples, Failures and pending in a variable which i can use with say command.


回答1:


You could write custom RSpec formatter and do your magic there. You can also have multiple formatters.

Check this resources for more information:

  • Custom formatters (Relish)
  • How to Use Multiple Formatters in RSpec 2
  • Source code base_text_formatter.rb


来源:https://stackoverflow.com/questions/15381037/rspec-how-to-capture-the-examples-failures-and-pending-count

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