minitest-reporters 1.3.0 → 1.3.1.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +27 -27
  3. data/.ruby-gemset +1 -1
  4. data/.travis.yml +10 -10
  5. data/.yardopts +5 -5
  6. data/CHANGELOG.md +58 -54
  7. data/Gemfile +2 -2
  8. data/LICENSE +19 -19
  9. data/README.md +134 -134
  10. data/Rakefile +60 -60
  11. data/lib/minitest/extensible_backtrace_filter.rb +67 -67
  12. data/lib/minitest/minitest_reporter_plugin.rb +75 -75
  13. data/lib/minitest/old_activesupport_fix.rb +24 -24
  14. data/lib/minitest/relative_position.rb +26 -26
  15. data/lib/minitest/reporters.rb +91 -91
  16. data/lib/minitest/reporters/ansi.rb +31 -31
  17. data/lib/minitest/reporters/base_reporter.rb +119 -117
  18. data/lib/minitest/reporters/default_reporter.rb +228 -228
  19. data/lib/minitest/reporters/html_reporter.rb +221 -221
  20. data/lib/minitest/reporters/junit_reporter.rb +158 -158
  21. data/lib/minitest/reporters/mean_time_reporter.rb +392 -392
  22. data/lib/minitest/reporters/progress_reporter.rb +96 -96
  23. data/lib/minitest/reporters/ruby_mate_reporter.rb +54 -54
  24. data/lib/minitest/reporters/rubymine_reporter.rb +117 -117
  25. data/lib/minitest/reporters/spec_reporter.rb +61 -61
  26. data/lib/minitest/reporters/version.rb +5 -5
  27. data/lib/minitest/templates/index.html.erb +82 -82
  28. data/minitest-reporters.gemspec +31 -31
  29. data/test/fixtures/junit_filename_bug_example_test.rb +21 -21
  30. data/test/fixtures/mean_time_test.rb +8 -8
  31. data/test/fixtures/progress_detailed_skip_test.rb +8 -8
  32. data/test/fixtures/progress_test.rb +8 -8
  33. data/test/fixtures/sample_test.rb +15 -15
  34. data/test/fixtures/spec_test.rb +13 -13
  35. data/test/gallery/bad_test.rb +25 -25
  36. data/test/gallery/good_test.rb +14 -14
  37. data/test/integration/reporters/junit_reporter_test.rb +12 -12
  38. data/test/integration/reporters/mean_time_reporter_test.rb +7 -7
  39. data/test/integration/reporters/progress_reporter_test.rb +34 -34
  40. data/test/test_helper.rb +22 -22
  41. data/test/unit/minitest/extensible_backtrace_filter_test.rb +42 -42
  42. data/test/unit/minitest/mean_time_reporter_unit_test.rb +152 -152
  43. data/test/unit/minitest/minitest_reporter_plugin_test.rb +14 -14
  44. data/test/unit/minitest/reporters_test.rb +65 -65
  45. data/test/unit/minitest/spec_reporter_test.rb +41 -41
  46. metadata +4 -4
@@ -1,96 +1,96 @@
1
- require 'ruby-progressbar'
2
-
3
- module Minitest
4
- module Reporters
5
- # Fuubar-like reporter with a progress bar.
6
- #
7
- # Based upon Jeff Kreefmeijer's Fuubar (MIT License) and paydro's
8
- # monkey-patch.
9
- #
10
- # @see https://github.com/jeffkreeftmeijer/fuubar Fuubar
11
- # @see https://gist.github.com/356945 paydro's monkey-patch
12
- class ProgressReporter < BaseReporter
13
- include RelativePosition
14
- include ANSI::Code
15
-
16
- PROGRESS_MARK = '='
17
-
18
- def initialize(options = {})
19
- super
20
- @detailed_skip = options.fetch(:detailed_skip, true)
21
-
22
- @progress = ProgressBar.create({
23
- total: total_count,
24
- starting_at: count,
25
- progress_mark: green(PROGRESS_MARK),
26
- remainder_mark: ' ',
27
- format: options.fetch(:format, ' %C/%c: [%B] %p%% %a, %e'),
28
- autostart: false
29
- })
30
- end
31
-
32
- def start
33
- super
34
- puts('Started with run options %s' % options[:args])
35
- puts
36
- @progress.start
37
- @progress.total = total_count
38
- show
39
- end
40
-
41
- def record(test)
42
- super
43
- return if test.skipped? && !@detailed_skip
44
- if test.failure
45
- print "\e[0m\e[1000D\e[K"
46
- print_colored_status(test)
47
- print_test_with_time(test)
48
- puts
49
- print_info(test.failure, test.error?)
50
- puts
51
- end
52
-
53
- if test.skipped? && color != "red"
54
- self.color = "yellow"
55
- elsif test.failure
56
- self.color = "red"
57
- end
58
-
59
- show
60
- end
61
-
62
- def report
63
- super
64
- @progress.finish
65
-
66
- puts
67
- puts('Finished in %.5fs' % total_time)
68
- print('%d tests, %d assertions, ' % [count, assertions])
69
- color = failures.zero? && errors.zero? ? :green : :red
70
- print(send(color) { '%d failures, %d errors, ' } % [failures, errors])
71
- print(yellow { '%d skips' } % skips)
72
- puts
73
- end
74
-
75
- private
76
-
77
- def show
78
- @progress.increment unless count == 0
79
- end
80
-
81
- def print_test_with_time(test)
82
- puts [test.name, test_class(test), total_time].inspect
83
- print(" %s#%s (%.2fs)" % [test.name, test_class(test), total_time])
84
- end
85
-
86
- def color
87
- @color ||= "green"
88
- end
89
-
90
- def color=(color)
91
- @color = color
92
- @progress.progress_mark = send(color, PROGRESS_MARK)
93
- end
94
- end
95
- end
96
- end
1
+ require 'ruby-progressbar'
2
+
3
+ module Minitest
4
+ module Reporters
5
+ # Fuubar-like reporter with a progress bar.
6
+ #
7
+ # Based upon Jeff Kreefmeijer's Fuubar (MIT License) and paydro's
8
+ # monkey-patch.
9
+ #
10
+ # @see https://github.com/jeffkreeftmeijer/fuubar Fuubar
11
+ # @see https://gist.github.com/356945 paydro's monkey-patch
12
+ class ProgressReporter < BaseReporter
13
+ include RelativePosition
14
+ include ANSI::Code
15
+
16
+ PROGRESS_MARK = '='
17
+
18
+ def initialize(options = {})
19
+ super
20
+ @detailed_skip = options.fetch(:detailed_skip, true)
21
+
22
+ @progress = ProgressBar.create({
23
+ total: total_count,
24
+ starting_at: count,
25
+ progress_mark: green(PROGRESS_MARK),
26
+ remainder_mark: ' ',
27
+ format: options.fetch(:format, ' %C/%c: [%B] %p%% %a, %e'),
28
+ autostart: false
29
+ })
30
+ end
31
+
32
+ def start
33
+ super
34
+ puts('Started with run options %s' % options[:args])
35
+ puts
36
+ @progress.start
37
+ @progress.total = total_count
38
+ show
39
+ end
40
+
41
+ def record(test)
42
+ super
43
+ return if test.skipped? && !@detailed_skip
44
+ if test.failure
45
+ print "\e[0m\e[1000D\e[K"
46
+ print_colored_status(test)
47
+ print_test_with_time(test)
48
+ puts
49
+ print_info(test.failure, test.error?)
50
+ puts
51
+ end
52
+
53
+ if test.skipped? && color != "red"
54
+ self.color = "yellow"
55
+ elsif test.failure
56
+ self.color = "red"
57
+ end
58
+
59
+ show
60
+ end
61
+
62
+ def report
63
+ super
64
+ @progress.finish
65
+
66
+ puts
67
+ puts('Finished in %.5fs' % total_time)
68
+ print('%d tests, %d assertions, ' % [count, assertions])
69
+ color = failures.zero? && errors.zero? ? :green : :red
70
+ print(send(color) { '%d failures, %d errors, ' } % [failures, errors])
71
+ print(yellow { '%d skips' } % skips)
72
+ puts
73
+ end
74
+
75
+ private
76
+
77
+ def show
78
+ @progress.increment unless count == 0
79
+ end
80
+
81
+ def print_test_with_time(test)
82
+ puts [test.name, test_class(test), total_time].inspect
83
+ print(" %s#%s (%.2fs)" % [test.name, test_class(test), total_time])
84
+ end
85
+
86
+ def color
87
+ @color ||= "green"
88
+ end
89
+
90
+ def color=(color)
91
+ @color = color
92
+ @progress.progress_mark = send(color, PROGRESS_MARK)
93
+ end
94
+ end
95
+ end
96
+ end
@@ -1,54 +1,54 @@
1
- module Minitest
2
- module Reporters
3
- # Simple reporter designed for RubyMate.
4
- class RubyMateReporter < BaseReporter
5
- include RelativePosition
6
-
7
- INFO_PADDING = 2
8
-
9
- def start
10
- super
11
- puts('Started with run options %s' % options[:args])
12
- puts
13
- end
14
-
15
- def record(test)
16
- super
17
- if test.skipped?
18
- print 'SKIP'
19
- print_test_with_time(test)
20
- puts
21
- puts
22
- elsif test.error?
23
- print 'ERROR'
24
- print_test_with_time(test)
25
- puts
26
- print_info(test.failure)
27
- puts
28
- elsif test.failure
29
- print 'FAIL'
30
- print_test_with_time(test)
31
- puts
32
- print_info(test.failure, false)
33
- puts
34
- end
35
- end
36
-
37
- def report
38
- super
39
- puts
40
- puts('Finished in %.5fs' % total_time)
41
- print('%d tests, %d assertions, ' % [count, assertions])
42
- print('%d failures, %d errors, ' % [failures, errors])
43
- print('%d skips' % skips)
44
- puts
45
- end
46
-
47
- private
48
-
49
- def print_test_with_time(test)
50
- print(" #{test.class}##{test.name} (%.2fs)" % test.time)
51
- end
52
- end
53
- end
54
- end
1
+ module Minitest
2
+ module Reporters
3
+ # Simple reporter designed for RubyMate.
4
+ class RubyMateReporter < BaseReporter
5
+ include RelativePosition
6
+
7
+ INFO_PADDING = 2
8
+
9
+ def start
10
+ super
11
+ puts('Started with run options %s' % options[:args])
12
+ puts
13
+ end
14
+
15
+ def record(test)
16
+ super
17
+ if test.skipped?
18
+ print 'SKIP'
19
+ print_test_with_time(test)
20
+ puts
21
+ puts
22
+ elsif test.error?
23
+ print 'ERROR'
24
+ print_test_with_time(test)
25
+ puts
26
+ print_info(test.failure)
27
+ puts
28
+ elsif test.failure
29
+ print 'FAIL'
30
+ print_test_with_time(test)
31
+ puts
32
+ print_info(test.failure, false)
33
+ puts
34
+ end
35
+ end
36
+
37
+ def report
38
+ super
39
+ puts
40
+ puts('Finished in %.5fs' % total_time)
41
+ print('%d tests, %d assertions, ' % [count, assertions])
42
+ print('%d failures, %d errors, ' % [failures, errors])
43
+ print('%d skips' % skips)
44
+ puts
45
+ end
46
+
47
+ private
48
+
49
+ def print_test_with_time(test)
50
+ print(" #{test.class}##{test.name} (%.2fs)" % test.time)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,117 +1,117 @@
1
- # Test results reporter for RubyMine IDE (http://www.jetbrains.com/ruby/) and
2
- # TeamCity(http://www.jetbrains.com/teamcity/) Continuous Integration Server
3
-
4
- begin
5
- require 'teamcity/runner_common'
6
- require 'teamcity/utils/service_message_factory'
7
- require 'teamcity/utils/runner_utils'
8
- require 'teamcity/utils/url_formatter'
9
- rescue LoadError
10
- require "minitest/reporters/default_reporter"
11
-
12
- # delegate to default reporter
13
- module Minitest
14
- module Reporters
15
- class RubyMineReporter < DefaultReporter
16
- def initialize(options = {})
17
- super
18
- puts("====================================================================================================\n")
19
- puts("RubyMine reporter works only if it test was launched using RubyMine IDE or TeamCity CI server !!!\n")
20
- puts("====================================================================================================\n")
21
- puts("Using default results reporter...\n")
22
- end
23
- end
24
- end
25
- end
26
- else
27
- module Minitest
28
- module Reporters
29
- class RubyMineReporter < BaseReporter
30
- include ANSI::Code
31
-
32
- include ::Rake::TeamCity::RunnerCommon
33
- include ::Rake::TeamCity::RunnerUtils
34
- include ::Rake::TeamCity::Utils::UrlFormatter
35
-
36
- def start
37
- super
38
- puts('Started with run options %s' % options[:args])
39
- puts
40
-
41
- # Setup test runner's MessageFactory
42
- set_message_factory(Rake::TeamCity::MessageFactory)
43
- log_test_reporter_attached
44
-
45
- # Report tests count:
46
- if ::Rake::TeamCity.is_in_idea_mode
47
- log(@message_factory.create_tests_count(total_count))
48
- elsif ::Rake::TeamCity.is_in_buildserver_mode
49
- log(@message_factory.create_progress_message("Starting.. (#{total_count} tests)"))
50
- end
51
-
52
- end
53
-
54
- def report
55
- super
56
-
57
- puts('Finished in %.5fs' % total_time)
58
- print('%d tests, %d assertions, ' % [count, assertions])
59
- print(red '%d failures, %d errors, ' % [failures, errors])
60
- print(yellow '%d skips' % skips)
61
- puts
62
- end
63
-
64
- def record(test)
65
- super
66
- unless test.passed?
67
- with_result(test) do |exception_msg, backtrace|
68
- if test.skipped?
69
- log(@message_factory.create_test_ignored(test.name, exception_msg, backtrace))
70
- elsif test.error?
71
- log(@message_factory.create_test_error(test.name, exception_msg, backtrace))
72
- else
73
- log(@message_factory.create_test_failed(test.name, exception_msg, backtrace))
74
- end
75
- end
76
- end
77
- log(@message_factory.create_test_finished(test.name, get_time_in_ms(test.time)))
78
- end
79
-
80
- alias_method :output, :io
81
-
82
- def before_suite(suite)
83
- fqn = suite.name
84
- log(@message_factory.create_suite_started(suite.name, location_from_ruby_qualified_name(fqn)))
85
- end
86
-
87
- def after_suite(suite)
88
- log(@message_factory.create_suite_finished(suite.name))
89
- end
90
-
91
- def before_test(test)
92
- super
93
- location = test.class.instance_method(test.name).source_location
94
- log(@message_factory.create_test_started(test.name, "file://#{location[0]}:#{location[1]}"))
95
- end
96
-
97
- #########
98
- def log(msg)
99
- output.flush
100
- output.puts("\n#{msg}")
101
- output.flush
102
-
103
- # returns:
104
- msg
105
- end
106
-
107
- def with_result(test)
108
- exception = test.failure
109
- msg = exception.nil? ? "" : "#{exception.class.name}: #{exception.message}"
110
- backtrace = exception.nil? ? "" : filter_backtrace(exception.backtrace).join("\n")
111
-
112
- yield(msg, backtrace)
113
- end
114
- end
115
- end
116
- end
117
- end
1
+ # Test results reporter for RubyMine IDE (http://www.jetbrains.com/ruby/) and
2
+ # TeamCity(http://www.jetbrains.com/teamcity/) Continuous Integration Server
3
+
4
+ begin
5
+ require 'teamcity/runner_common'
6
+ require 'teamcity/utils/service_message_factory'
7
+ require 'teamcity/utils/runner_utils'
8
+ require 'teamcity/utils/url_formatter'
9
+ rescue LoadError
10
+ require "minitest/reporters/default_reporter"
11
+
12
+ # delegate to default reporter
13
+ module Minitest
14
+ module Reporters
15
+ class RubyMineReporter < DefaultReporter
16
+ def initialize(options = {})
17
+ super
18
+ puts("====================================================================================================\n")
19
+ puts("RubyMine reporter works only if it test was launched using RubyMine IDE or TeamCity CI server !!!\n")
20
+ puts("====================================================================================================\n")
21
+ puts("Using default results reporter...\n")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ else
27
+ module Minitest
28
+ module Reporters
29
+ class RubyMineReporter < BaseReporter
30
+ include ANSI::Code
31
+
32
+ include ::Rake::TeamCity::RunnerCommon
33
+ include ::Rake::TeamCity::RunnerUtils
34
+ include ::Rake::TeamCity::Utils::UrlFormatter
35
+
36
+ def start
37
+ super
38
+ puts('Started with run options %s' % options[:args])
39
+ puts
40
+
41
+ # Setup test runner's MessageFactory
42
+ set_message_factory(Rake::TeamCity::MessageFactory)
43
+ log_test_reporter_attached
44
+
45
+ # Report tests count:
46
+ if ::Rake::TeamCity.is_in_idea_mode
47
+ log(@message_factory.create_tests_count(total_count))
48
+ elsif ::Rake::TeamCity.is_in_buildserver_mode
49
+ log(@message_factory.create_progress_message("Starting.. (#{total_count} tests)"))
50
+ end
51
+
52
+ end
53
+
54
+ def report
55
+ super
56
+
57
+ puts('Finished in %.5fs' % total_time)
58
+ print('%d tests, %d assertions, ' % [count, assertions])
59
+ print(red '%d failures, %d errors, ' % [failures, errors])
60
+ print(yellow '%d skips' % skips)
61
+ puts
62
+ end
63
+
64
+ def record(test)
65
+ super
66
+ unless test.passed?
67
+ with_result(test) do |exception_msg, backtrace|
68
+ if test.skipped?
69
+ log(@message_factory.create_test_ignored(test.name, exception_msg, backtrace))
70
+ elsif test.error?
71
+ log(@message_factory.create_test_error(test.name, exception_msg, backtrace))
72
+ else
73
+ log(@message_factory.create_test_failed(test.name, exception_msg, backtrace))
74
+ end
75
+ end
76
+ end
77
+ log(@message_factory.create_test_finished(test.name, get_time_in_ms(test.time)))
78
+ end
79
+
80
+ alias_method :output, :io
81
+
82
+ def before_suite(suite)
83
+ fqn = suite.name
84
+ log(@message_factory.create_suite_started(suite.name, location_from_ruby_qualified_name(fqn)))
85
+ end
86
+
87
+ def after_suite(suite)
88
+ log(@message_factory.create_suite_finished(suite.name))
89
+ end
90
+
91
+ def before_test(test)
92
+ super
93
+ location = test.class.instance_method(test.name).source_location
94
+ log(@message_factory.create_test_started(test.name, "file://#{location[0]}:#{location[1]}"))
95
+ end
96
+
97
+ #########
98
+ def log(msg)
99
+ output.flush
100
+ output.puts("\n#{msg}")
101
+ output.flush
102
+
103
+ # returns:
104
+ msg
105
+ end
106
+
107
+ def with_result(test)
108
+ exception = test.failure
109
+ msg = exception.nil? ? "" : "#{exception.class.name}: #{exception.message}"
110
+ backtrace = exception.nil? ? "" : filter_backtrace(exception.backtrace).join("\n")
111
+
112
+ yield(msg, backtrace)
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end