目前,我正在运行超过1k个示例,并且需要很长时间才能完成(超过20 minutes!!!个).

我想确定哪些示例需要更多的时间来完成,有没有办法运行rspec并返回每个示例(单独)完成所需的时间?我用rspec 1.3.0rspec-rails 1.2.3

推荐答案

您可以使用评测列出10个最慢的示例:

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

如果你在一个特定的测试套件上运行这个测试,你可以从一个较小的示例子集中得到10个最慢的示例:

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

Rspec的更新版本

对于较新版本的rspec,您应该使用--profile选项:

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

Ruby-on-rails相关问答推荐

Rails 7.1中的覆盖脚手架控制器

为什么Rails数值验证器不使用规格化值?

在PDF生成中渲染 colored颜色

Grape api (rails) - 未初始化常量 Endpoints::TodoAPI (NameError)

组合 active_record 模型并按共享属性排序

ViewModel 和 Controller 有什么区别?

将日期时间转换为月、日和年?

blueprint/screen.css 未预编译

Rails cron 与时俱进,设置环境

从 Authlogic 迁移到 Devise

Rails - 使用 %W

rails 4.0, rake db:sessions:create

Rails如何对列求和?

Ruby on Rails - link_to 按钮 / css

如何在 VS Code 中自动格式化 Ruby 或 .erb 文件?

Rails 控制台中手动更新属性值的验证问题

您如何查看 ruby​​ 中的调用堆栈示例?

使用连接的 Ruby on Rails ActiveRecord 查询

将现有的 html.erb 转换为 Haml

设置EDITOR或BUNDLER_EDITOR环境变量