Class: Minitest::Queue::GrindReporter
- Inherits:
-
Reporters::BaseReporter
- Object
- Reporters::BaseReporter
- Minitest::Queue::GrindReporter
- Includes:
- CI::Queue::OutputHelpers
- Defined in:
- lib/minitest/queue/grind_reporter.rb
Instance Method Summary collapse
- #fetch_counts(test) ⇒ Object
- #flaky_tests ⇒ Object
-
#initialize(build:, **options) ⇒ GrindReporter
constructor
A new instance of GrindReporter.
- #record ⇒ Object
- #report ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(build:, **options) ⇒ GrindReporter
Returns a new instance of GrindReporter.
9 10 11 12 13 |
# File 'lib/minitest/queue/grind_reporter.rb', line 9 def initialize(build:, **) @build = build @success = true super() end |
Instance Method Details
#fetch_counts(test) ⇒ Object
64 65 66 67 |
# File 'lib/minitest/queue/grind_reporter.rb', line 64 def fetch_counts(test) key = "count##{test}" build.fetch_stats([key])[key] end |
#flaky_tests ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/minitest/queue/grind_reporter.rb', line 47 def flaky_tests @flaky_tests ||= begin flaky_tests = {} build.error_reports.each do |error| err = ErrorReport.load(error) name = err.test_and_module_name flaky_tests[name] ||= [] flaky_tests[name] << err end flaky_tests end end |
#record ⇒ Object
60 61 62 |
# File 'lib/minitest/queue/grind_reporter.rb', line 60 def record(*) raise NotImplementedError end |
#report ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/minitest/queue/grind_reporter.rb', line 15 def report puts '+++ Results' if flaky_tests.empty? puts green('all tests passed every time, grinding did not uncover any flakiness') return end @success = false flaky_tests.each do |name, errors| total_runs = fetch_counts(name) flakiness_percentage = (errors.count / total_runs) * 100 = errors.map do || .to_s.lines.map { |l| "\t#{l}"}.join end.to_set.to_a.join("\n\n") puts <<~EOS #{red(name)} Runs: #{total_runs.to_i} Failures: #{errors.count} Flakiness Percentage: #{flakiness_percentage.to_i}% Errors: #{} EOS end end |
#success? ⇒ Boolean
43 44 45 |
# File 'lib/minitest/queue/grind_reporter.rb', line 43 def success? @success end |