What is it?
Top tests displays your 10 slowest tests after execution. The goal is to help you keeping your tests fast.
Moreover top tests can break your build if any test is taking longer than a specified duration.
Since version 0.0.4, Top tests works only with Ruby 2.0 and Rails 4.0
How to use it?
Add to your Gemfile.
group :test do
gem 'top_tests'
end
Then require top tests and just include it into your test class:
class SampleTest < MiniTest::Unit::TestCase
include TopTests
# Break your build if any test's duration is longer than ...
self.max_duration = 0.5 # Optional, nil by default (in seconds)
end
Sample output:
Top 10 slowest tests:
0.429 ApplicationControllerTest#test_notify_error
0.322 HoneyBadgersControllerTest#test_show
0.200 BearsControllerTest#test_destroy_collection
0.134 SuricatsControllerTest#test_can_not_update
0.124 SuricatsControllerTest#test_create
0.105 SuricatsControllerTest#test_update
0.096 HoneyBadgersControllerTest#test_create
0.093 HoneyBadgersControllerTest#test_update
0.091 SuricatsControllerTest#test_destroy
0.090 HoneyBadgersControllerTest#test_show
Sample output when few tests are too slow:
TEST?FAIL! 3 test(s) are taking longer than 0.2 seconds:
0.410 HoneyBadgerTest#test_fighting_a_cobra
0.228 SuricatTest#test_caught_by_an_eagle
0.203 HoneyBadgerTest#test_eating_larvae