如何总体分析我的 Ruby 测试套件?
通常的悲伤故事:我的测试运行缓慢。
我的第一个想法是分析整个测试套件以寻找明显的胜利(消除网络访问或缓存),因此我添加了一个 ruby-prof 任务:
RubyProf::ProfileTask.new(:units) do |t|
t.test_files = FileList[RAILS_ROOT + '/test/unit/**/*_test.rb']
t.output_dir = Dir.tmpdir
t.printer = :graph
t.min_percent = 1
end
不幸的是,这单独分析了每个测试。有没有办法获得所有这些测试类的汇总?
The usual sob story: my tests are running slowly.
My first thought was to profile the whole test suite to look for obvious wins (stubbing out network access or caches), so I added a ruby-prof task:
RubyProf::ProfileTask.new(:units) do |t|
t.test_files = FileList[RAILS_ROOT + '/test/unit/**/*_test.rb']
t.output_dir = Dir.tmpdir
t.printer = :graph
t.min_percent = 1
end
Unfortunately, this profiles each test individually. Is there a way to get an aggregate over all of those test classes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以运行
ruby-prof test_suite_name.rb
。您甚至不需要在测试中添加任何 ruby-prof 特定代码。You can run
ruby-prof test_suite_name.rb
. You don't even need to add any ruby-prof specific code to your tests.计划向 minitest 添加基准测试。
There are plans to add benchmarking to minitest.