Show runtime for each rspec example

余生长醉 提交于 2020-01-29 03:18:52

问题


currently I'm running more than 1k examples and it's taking a long time to complete (more than 20 minutes!!!).

I'd like to identify which examples are the ones taking more time to complete, is there any way to run rspec and return the time each example takes to complete(individually)? I'm using rspec 1.3.0 and rspec-rails 1.2.3


回答1:


You can use profiling to list your 10 slowest examples:

spec -p spec/*/*_spec.rb --colour --format profile

If you run this on a specific test suite you can get the 10 slowest examples from a smaller subset of examples:

spec -p spec/models/user_spec.rb --format profile

Newer Versions of Rspec

For newer versions of rspec you should use the --profile option:

rspec spec/ --profile         | (shows the 10 slowest examples)
rspec spec/ --profile 2       | (shows the 2  slowest examples)


来源:https://stackoverflow.com/questions/4856500/show-runtime-for-each-rspec-example

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