class Minitest::Reporters::LitrReporter

Minitest reporter for litr (github.com/Lothiraldan/litr)

Public Instance Methods

record(test) click to toggle source
Calls superclass method
# File lib/minitest/reporters/litr_reporter.rb, line 14
def record(test)
  super
  test_location = location(test)

  p test.methods.sort if test.skipped?

  print JSON.generate(
    _type: 'test_result', id: identifier(test), outcome: outcome(test), test_name: identifier(test),
    duration: test.time, errors: errors(test),
    file: test_location[0], line: test_location[1]
  )
  print "\n"
end
start() click to toggle source
Calls superclass method
# File lib/minitest/reporters/litr_reporter.rb, line 7
def start
  super

  print JSON.generate(_type: 'session_start', test_number: total_count)
  print "\n"
end

Private Instance Methods

errors(test) click to toggle source
# File lib/minitest/reporters/litr_reporter.rb, line 34
def errors(test)
  test.failures.map do |failure|
    Hash[message: failure.message, backtrace: failure.backtrace]
  end
end
identifier(test) click to toggle source
# File lib/minitest/reporters/litr_reporter.rb, line 40
def identifier(test)
  test.location.gsub(/\s\[(.*)\]/, '')
end
location(test) click to toggle source
# File lib/minitest/reporters/litr_reporter.rb, line 30
def location(test)
  test.method(test.name.to_s).source_location
end
outcome(test) click to toggle source
# File lib/minitest/reporters/litr_reporter.rb, line 44
def outcome(test)
  return 'skip' if test.skipped?
  return 'passed' if test.passed?
  return 'error' if test.error?
  return 'failure' if test.failure
end