top_tests 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +3 -1
- data/README.rdoc +37 -4
- data/lib/top_tests/version.rb +1 -1
- data/lib/top_tests.rb +17 -11
- data/test/failing_test.rb +14 -0
- data/test/fast_test.rb +16 -0
- data/test/slow_test.rb +19 -0
- data/top_tests.gemspec +4 -4
- metadata +14 -13
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: e7dda877ea636154577883b27d5d45909ace9d6c
|
|
4
|
+
data.tar.gz: 13d749b4704108b1bde1ed72e682b0d5d1acc7b9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: cd223c0d87ed0f7a3823ba5e22d7459efc5a9764ed25b4b3af26b9ba1f56dbdd4d4aa0fe0f29eb1b81a36e53415716c39d5736445245a73bdf52b2e0f54eee9d
|
|
7
|
+
data.tar.gz: 2e019d6d355d95d76effcdc54eeca92e332179732a39ba44c44ceb072d25db6cafb3f07503366d4d6cfe47c629aaf9c0358415922e3dfbd57008d356cadc7e35
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
|
@@ -2,11 +2,44 @@
|
|
|
2
2
|
Top tests displays your 10 slowest tests after execution. The goal is to help you
|
|
3
3
|
keeping your tests fast.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
First of all top tests works only with ActiveSupport::TestCase. Then require top
|
|
7
|
-
tests and just include into your test class:
|
|
5
|
+
Moreover top tests can break your build if any test is taking longer than a specified duration.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
Since version 0.0.4, Top tests works only with Ruby 2.0 and Rails 4.0
|
|
8
|
+
|
|
9
|
+
== How to use it?
|
|
10
|
+
Add to your Gemfile.
|
|
11
|
+
|
|
12
|
+
group :test do
|
|
13
|
+
gem 'top_tests'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Then require top tests and just include it into your test class:
|
|
17
|
+
|
|
18
|
+
class SampleTest < MiniTest::Unit::TestCase
|
|
10
19
|
include TopTests
|
|
20
|
+
|
|
21
|
+
# Break your build if any test's duration is longer than ...
|
|
22
|
+
self.max_duration = 0.5 # Optional, nil by default (in seconds)
|
|
11
23
|
end
|
|
12
24
|
|
|
25
|
+
Sample output:
|
|
26
|
+
|
|
27
|
+
Top 10 slowest tests:
|
|
28
|
+
0.429 ApplicationControllerTest#test_notify_error
|
|
29
|
+
0.322 HoneyBadgersControllerTest#test_show
|
|
30
|
+
0.200 BearsControllerTest#test_destroy_collection
|
|
31
|
+
0.134 SuricatsControllerTest#test_can_not_update
|
|
32
|
+
0.124 SuricatsControllerTest#test_create
|
|
33
|
+
0.105 SuricatsControllerTest#test_update
|
|
34
|
+
0.096 HoneyBadgersControllerTest#test_create
|
|
35
|
+
0.093 HoneyBadgersControllerTest#test_update
|
|
36
|
+
0.091 SuricatsControllerTest#test_destroy
|
|
37
|
+
0.090 HoneyBadgersControllerTest#test_show
|
|
38
|
+
|
|
39
|
+
Sample output when few tests are too slow:
|
|
40
|
+
|
|
41
|
+
TEST?FAIL! 3 test(s) are taking longer than 0.2 seconds:
|
|
42
|
+
0.410 HoneyBadgerTest#test_fighting_a_cobra
|
|
43
|
+
0.228 SuricatTest#test_caught_by_an_eagle
|
|
44
|
+
0.203 HoneyBadgerTest#test_eating_larvae
|
|
45
|
+
|
data/lib/top_tests/version.rb
CHANGED
data/lib/top_tests.rb
CHANGED
|
@@ -7,23 +7,25 @@ module TopTests
|
|
|
7
7
|
#####################
|
|
8
8
|
|
|
9
9
|
def self.included(klass)
|
|
10
|
-
klass.setup :start_timer
|
|
11
|
-
klass.teardown :stop_timer
|
|
12
10
|
klass.extend(ClassMethods)
|
|
13
|
-
|
|
11
|
+
MiniTest::Unit.after_tests { klass.after_all_tests }
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
########################
|
|
17
15
|
### Instance methods ###
|
|
18
16
|
########################
|
|
19
17
|
|
|
20
|
-
def
|
|
18
|
+
def before_setup
|
|
19
|
+
super
|
|
21
20
|
@timer_started_at = Time.now
|
|
22
21
|
end
|
|
23
22
|
|
|
24
|
-
def
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
def after_teardown
|
|
24
|
+
super
|
|
25
|
+
if @timer_started_at # Unset when a setup hook fails before top test.
|
|
26
|
+
name = self.class.to_s + '#' + @__name__
|
|
27
|
+
self.class.tests_durations << [name, Time.now - @timer_started_at]
|
|
28
|
+
end
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
#####################
|
|
@@ -40,7 +42,7 @@ module TopTests
|
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
def max_duration
|
|
43
|
-
@@max_duration
|
|
45
|
+
@@max_duration ||= nil
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
def top_tests
|
|
@@ -56,21 +58,25 @@ module TopTests
|
|
|
56
58
|
end
|
|
57
59
|
|
|
58
60
|
def print_top_tests
|
|
59
|
-
puts "\nTop tests:"
|
|
61
|
+
puts "\nTop 10 slowest tests:"
|
|
60
62
|
puts format_tests(top_tests.shift(10))
|
|
61
63
|
puts
|
|
62
64
|
end
|
|
63
65
|
|
|
64
66
|
def check_tests_duration
|
|
65
67
|
if !slow_tests.empty?
|
|
66
|
-
|
|
68
|
+
if slow_tests.size == 1
|
|
69
|
+
puts "\nTEST?FAIL! 1 test is taking longer than #{max_duration} seconds:"
|
|
70
|
+
else
|
|
71
|
+
puts "\nTEST?FAIL! #{slow_tests.count} tests are taking longer than #{max_duration} seconds:"
|
|
72
|
+
end
|
|
67
73
|
puts format_tests(slow_tests)
|
|
68
74
|
puts
|
|
69
75
|
exit 1
|
|
70
76
|
end
|
|
71
77
|
end
|
|
72
78
|
|
|
73
|
-
def
|
|
79
|
+
def after_all_tests
|
|
74
80
|
check_tests_duration
|
|
75
81
|
print_top_tests
|
|
76
82
|
end
|
data/test/fast_test.rb
ADDED
data/test/slow_test.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require 'minitest/autorun'
|
|
4
|
+
require 'top_tests'
|
|
5
|
+
|
|
6
|
+
class SlowTest < MiniTest::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
include TopTests
|
|
9
|
+
|
|
10
|
+
self.max_duration = 0.5
|
|
11
|
+
|
|
12
|
+
def test_good
|
|
13
|
+
sleep(0.5)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_bad
|
|
17
|
+
assert(true)
|
|
18
|
+
end
|
|
19
|
+
end
|
data/top_tests.gemspec
CHANGED
|
@@ -6,10 +6,10 @@ Gem::Specification.new do |s|
|
|
|
6
6
|
s.name = 'top_tests'
|
|
7
7
|
s.version = TopTests::VERSION.dup
|
|
8
8
|
s.authors = ['Alexis Bernard']
|
|
9
|
-
s.email = ['alexis@
|
|
10
|
-
s.homepage = 'https://github.com/
|
|
11
|
-
s.summary = 'Top tests
|
|
12
|
-
s.description = 'Top tests
|
|
9
|
+
s.email = ['alexis@bernard.io']
|
|
10
|
+
s.homepage = 'https://github.com/alexisbernard/top_tests'
|
|
11
|
+
s.summary = 'Top tests lists the 10 slowest tests after execution'
|
|
12
|
+
s.description = 'Top tests lists the 10 slowest tests after execution'
|
|
13
13
|
|
|
14
14
|
s.files = `git ls-files`.split("\n")
|
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: top_tests
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.0.4
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Alexis Bernard
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
|
13
12
|
dependencies: []
|
|
14
|
-
description: Top tests
|
|
13
|
+
description: Top tests lists the 10 slowest tests after execution
|
|
15
14
|
email:
|
|
16
|
-
- alexis@
|
|
15
|
+
- alexis@bernard.io
|
|
17
16
|
executables: []
|
|
18
17
|
extensions: []
|
|
19
18
|
extra_rdoc_files: []
|
|
@@ -26,29 +25,31 @@ files:
|
|
|
26
25
|
- Rakefile
|
|
27
26
|
- lib/top_tests.rb
|
|
28
27
|
- lib/top_tests/version.rb
|
|
28
|
+
- test/failing_test.rb
|
|
29
|
+
- test/fast_test.rb
|
|
30
|
+
- test/slow_test.rb
|
|
29
31
|
- top_tests.gemspec
|
|
30
|
-
homepage: https://github.com/
|
|
32
|
+
homepage: https://github.com/alexisbernard/top_tests
|
|
31
33
|
licenses: []
|
|
34
|
+
metadata: {}
|
|
32
35
|
post_install_message:
|
|
33
36
|
rdoc_options: []
|
|
34
37
|
require_paths:
|
|
35
38
|
- lib
|
|
36
39
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
37
|
-
none: false
|
|
38
40
|
requirements:
|
|
39
|
-
- -
|
|
41
|
+
- - '>='
|
|
40
42
|
- !ruby/object:Gem::Version
|
|
41
43
|
version: '0'
|
|
42
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
|
-
none: false
|
|
44
45
|
requirements:
|
|
45
|
-
- -
|
|
46
|
+
- - '>='
|
|
46
47
|
- !ruby/object:Gem::Version
|
|
47
48
|
version: '0'
|
|
48
49
|
requirements: []
|
|
49
50
|
rubyforge_project:
|
|
50
|
-
rubygems_version:
|
|
51
|
+
rubygems_version: 2.0.0.rc.2
|
|
51
52
|
signing_key:
|
|
52
|
-
specification_version:
|
|
53
|
-
summary: Top tests
|
|
53
|
+
specification_version: 4
|
|
54
|
+
summary: Top tests lists the 10 slowest tests after execution
|
|
54
55
|
test_files: []
|