class QUnited::Formatter::Dots

Public Instance Methods

start() click to toggle source
Calls superclass method QUnited::Formatter::Base#start
# File lib/qunited/formatter/dots.rb, line 4
def start
  super
  output.print "\n# Running JavaScript tests with #{driver_name}:\n\n"
end
summarize() click to toggle source
# File lib/qunited/formatter/dots.rb, line 19
def summarize
  output.print "\n\n#{times_line}\n"
  output.print failure_output
  output.print "\n#{bottom_line}\n"
end
test_failed(result) click to toggle source
Calls superclass method QUnited::Formatter::Base#test_failed
# File lib/qunited/formatter/dots.rb, line 14
def test_failed(result)
  super result
  output.print(result.error? ? 'E' : 'F')
end
test_passed(result) click to toggle source
Calls superclass method QUnited::Formatter::Base#test_passed
# File lib/qunited/formatter/dots.rb, line 9
def test_passed(result)
  super result
  output.print '.'
end

Private Instance Methods

bottom_line() click to toggle source
# File lib/qunited/formatter/dots.rb, line 62
def bottom_line
  "#{total_tests} tests, #{total_assertions} assertions, " +
    "#{total_failures} failures, #{total_errors} errors"
end
failure_output() click to toggle source
# File lib/qunited/formatter/dots.rb, line 27
def failure_output
  return '' unless total_failures > 0

  all_failure_output = ''
  count = 1
  failures.each do |test|
    test.assertions.reject { |a| a.passed? }.each do |assertion|
      file_name_output = (test.file && !test.file.strip.empty?) ? " [#{test.file}]" : ''
      msg = "\n  " + (count ? "#{count.to_s}) " : "")
      msg << "#{assertion.error? ? 'Error' : 'Failure'}:\n"
      msg << "#{test.name} (#{test.module_name})#{file_name_output}\n"
      msg << "#{assertion.message || 'Failed assertion, no message given.'}\n"

      if assertion.data.key? :expected
        msg << "Expected: #{assertion.expected.nil? ? 'null' : assertion.expected.inspect}\n"
        msg << "  Actual: #{assertion.actual.nil? ? 'null' : assertion.actual.inspect}\n"
      end
      all_failure_output << msg
      count += 1
    end
  end

  all_failure_output
end
failures() click to toggle source
# File lib/qunited/formatter/dots.rb, line 67
def failures
  test_results.select { |tr| tr.failed? }
end
times_line() click to toggle source
# File lib/qunited/formatter/dots.rb, line 52
def times_line
  total_time = test_results.inject(0) { |total, result| total += result.duration }

  tests_per = (total_time > 0) ? (total_tests / total_time) : total_tests
  assertions_per = (total_time > 0) ? (total_assertions / total_time) : total_assertions

  "Finished in #{"%.6g" % total_time} seconds, #{"%.6g" % tests_per} tests/s, " +
    "#{"%.6g" % assertions_per} assertions/s."
end
total_assertions() click to toggle source
# File lib/qunited/formatter/dots.rb, line 85
def total_assertions
  test_results.inject(0) { |total, result| total += result.assertions.size}
end
total_errors() click to toggle source

Test errors, not assertion errors

# File lib/qunited/formatter/dots.rb, line 81
def total_errors
  test_results.select { |tr| tr.error? }.size
end
total_failures() click to toggle source

Test failures, not assertion failures

# File lib/qunited/formatter/dots.rb, line 76
def total_failures
  failures.size
end
total_tests() click to toggle source
# File lib/qunited/formatter/dots.rb, line 71
def total_tests
  test_results.size
end