class TestMinitestReporter

Constants

SKIP_MSG

Attributes

io[RW]
r[RW]

Public Instance Methods

error_test() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 43
def error_test
  unless defined? @et then
    @et = Minitest::Test.new(:woot)
    @et.failures << Minitest::UnexpectedError.new(begin
                                                    raise "no"
                                                  rescue => e
                                                    e
                                                  end)
    @et = Minitest::Result.from @et
  end
  @et
end
fail_test() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 56
def fail_test
  unless defined? @ft then
    @ft = Minitest::Test.new(:woot)
    @ft.failures <<   begin
                        raise Minitest::Assertion, "boo"
                      rescue Minitest::Assertion => e
                        e
                      end
    @ft = Minitest::Result.from @ft
  end
  @ft
end
new_composite_reporter() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 14
def new_composite_reporter
  reporter = Minitest::CompositeReporter.new
  reporter << Minitest::SummaryReporter.new(self.io)
  reporter << Minitest::ProgressReporter.new(self.io)

  def reporter.first
    reporters.first
  end

  def reporter.results
    first.results
  end

  def reporter.count
    first.count
  end

  def reporter.assertions
    first.assertions
  end

  reporter
end
passing_test() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 69
def passing_test
  @pt ||= Minitest::Result.from Minitest::Test.new(:woot)
end
setup() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 38
def setup
  self.io = StringIO.new("")
  self.r  = new_composite_reporter
end
skip_test() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 73
def skip_test
  unless defined? @st then
    @st = Minitest::Test.new(:woot)
    @st.failures << begin
                      raise Minitest::Skip
                    rescue Minitest::Assertion => e
                      e
                    end
    @st = Minitest::Result.from @st
  end
  @st
end
test_passed_eh_empty() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 92
def test_passed_eh_empty
  assert_predicate r, :passed?
end
test_passed_eh_error() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 104
def test_passed_eh_error
  r.start

  r.results << error_test

  refute_predicate r, :passed?

  r.report

  refute_match SKIP_MSG, io.string
end
test_passed_eh_failure() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 96
def test_passed_eh_failure
  r.results << fail_test

  refute_predicate r, :passed?
end
test_passed_eh_skipped() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 116
def test_passed_eh_skipped
  r.start
  r.results << skip_test
  assert r.passed?

  restore_env do
    r.report
  end

  assert_match SKIP_MSG, io.string
end
test_passed_eh_skipped_verbose() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 128
def test_passed_eh_skipped_verbose
  r.first.options[:verbose] = true

  r.start
  r.results << skip_test
  assert r.passed?
  r.report

  refute_match SKIP_MSG, io.string
end
test_record_error() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 166
def test_record_error
  error_test = self.error_test
  r.record error_test

  assert_equal "E", io.string
  assert_equal [error_test], r.results
  assert_equal 1, r.count
  assert_equal 0, r.assertions
end
test_record_fail() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 156
def test_record_fail
  fail_test = self.fail_test
  r.record fail_test

  assert_equal "F", io.string
  assert_equal [fail_test], r.results
  assert_equal 1, r.count
  assert_equal 0, r.assertions
end
test_record_pass() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 147
def test_record_pass
  r.record passing_test

  assert_equal ".", io.string
  assert_empty r.results
  assert_equal 1, r.count
  assert_equal 0, r.assertions
end
test_record_skip() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 176
def test_record_skip
  skip_test = self.skip_test
  r.record skip_test

  assert_equal "S", io.string
  assert_equal [skip_test], r.results
  assert_equal 1, r.count
  assert_equal 0, r.assertions
end
test_report_empty() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 186
  def test_report_empty
    r.start
    r.report

    exp = clean <<-EOM
      Run options:

      # Running:



      Finished in 0.00

      0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
    EOM

    assert_equal exp, normalize_output(io.string)
  end
test_report_error() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 249
  def test_report_error
    r.start
    r.record error_test
    r.report

    exp = clean <<-EOM
      Run options:

      # Running:

      E

      Finished in 0.00

        1) Error:
      Minitest::Test#woot:
      RuntimeError: no
          FILE:LINE:in `error_test'
          FILE:LINE:in `test_report_error'

      1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
    EOM

    assert_equal exp, normalize_output(io.string)
  end
test_report_failure() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 225
  def test_report_failure
    r.start
    r.record fail_test
    r.report

    exp = clean <<-EOM
      Run options:

      # Running:

      F

      Finished in 0.00

        1) Failure:
      Minitest::Test#woot [FILE:LINE]:
      boo

      1 runs, 0 assertions, 1 failures, 0 errors, 0 skips
    EOM

    assert_equal exp, normalize_output(io.string)
  end
test_report_passing() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 205
  def test_report_passing
    r.start
    r.record passing_test
    r.report

    exp = clean <<-EOM
      Run options:

      # Running:

      .

      Finished in 0.00

      1 runs, 0 assertions, 0 failures, 0 errors, 0 skips
    EOM

    assert_equal exp, normalize_output(io.string)
  end
test_report_skipped() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 275
  def test_report_skipped
    r.start
    r.record skip_test

    restore_env do
      r.report
    end

    exp = clean <<-EOM
      Run options:

      # Running:

      S

      Finished in 0.00

      1 runs, 0 assertions, 0 failures, 0 errors, 1 skips

      You have skipped tests. Run with --verbose for details.
    EOM

    assert_equal exp, normalize_output(io.string)
  end
test_start() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 139
def test_start
  r.start

  exp = "Run options: \n\n# Running:\n\n"

  assert_equal exp, io.string
end
test_to_s() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_reporter.rb, line 86
def test_to_s
  r.record passing_test
  r.record fail_test
  assert_match "woot", r.first.to_s
end