class RComp::Reporter

Constants

GEN_JUSTIFY
PADDING
TEST_JUSTIFY

Public Class Methods

new(type) click to toggle source

Initialize a new Reporter

type - The type (Symbol) of the suite

Initialize counters for all result types

# File lib/rcomp/reporter.rb, line 18
def initialize(type)
  @type = type
  @success = 0
  @skipped = 0
  @failed = 0
end

Public Instance Methods

header() click to toggle source

Prints header for test suite report

Returns nothing

# File lib/rcomp/reporter.rb, line 67
def header
  # The suite is a test suite
  if @type == :test
    puts "RComp: running test suite..."

  # The suite is a generation suite
  else
    puts "RComp: generating expected output..."
  end
  puts
end
report(test) click to toggle source

Main interface for reporting Reports the result of a single test or generation

test - A test object that has been run

Returns nothing

# File lib/rcomp/reporter.rb, line 31
def report(test)
  case test.result
  when :success
    if @type == :test
      print_test_success(test)
    else
      print_generate_success(test)
    end
    @success += 1

  when :skipped
    if @type == :test
      print_test_skipped(test)
    else
      print_generate_skipped(test)
    end
    @skipped += 1

  # Generate can't fail directly
  when :failed
    print_test_failed(test)
    @failed += 1

  when :timedout
    if @type == :test
      print_test_timeout(test)
    else
      print_generate_timeout(test)
    end
    @failed += 1
  end
end
summary() click to toggle source

Prints summary of test suite report

Returns nothing

# File lib/rcomp/reporter.rb, line 82
def summary
  print_summary
  exit 1 if @failed > 0
end

Private Instance Methods

print_generate_skipped(test) click to toggle source
print_generate_success(test) click to toggle source
print_generate_timeout(test) click to toggle source
print_skipped_generate_explanation() click to toggle source
print_skipped_test_explanation() click to toggle source
print_summary() click to toggle source
print_test_failed(test) click to toggle source
print_test_skipped(test) click to toggle source
print_test_success(test) click to toggle source
print_test_timeout(test) click to toggle source