目前我正在运行超过1k的示例,并且需要很长时间才能完成(超过 20分钟!!! )。
我想确定哪些示例需要花费更多时间才能完成,有没有办法运行rspec并返回每个示例完成(单独)所需的时间?我正在使用 rspec 1.3.0 和 rspec-rails 1.2.3
答案 0 :(得分:45)
您可以使用分析列出10个最慢的示例:
spec -p spec/*/*_spec.rb --colour --format profile
如果您在特定测试套件上运行此操作,您可以从较小的示例子集中获取10个最慢的示例:
spec -p spec/models/user_spec.rb --format profile
对于较新版本的rspec,您应该使用--profile
选项:
rspec spec/ --profile | (shows the 10 slowest examples)
rspec spec/ --profile 2 | (shows the 2 slowest examples)