File: test-pending.rb

package info (click to toggle)
ruby-test-unit 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 928 kB
  • ctags: 1,759
  • sloc: ruby: 12,818; makefile: 6
file content (70 lines) | stat: -rw-r--r-- 2,007 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
require 'test/unit'
require 'testunit-test-util'

class TestUnitPending < Test::Unit::TestCase
  include TestUnitTestUtil

  class TestCase < Test::Unit::TestCase
    class << self
      def suite
        Test::Unit::TestSuite.new(name)
      end
    end

    def test_pend
      pend("1st pend")
      pend("2nd pend. Should not be reached here.")
      assert(true, "Should not be reached here too.")
    end

    def test_pend_with_failure_in_block
      pend("Wait a minute") do
        raise "Not implemented yet"
      end
      assert(true, "Reached here.")
    end

    def test_pend_with_no_failure_in_block
      pend("Wait a minute") do
        "Nothing raised"
      end
      assert(true, "Not reached here.")
    end
  end

  def test_pend
    test = nil
    result = _run_test("test_pend") {|t| test = t}
    assert_equal("1 tests, 0 assertions, 0 failures, 0 errors, 1 pendings, " \
                 "0 omissions, 0 notifications",
                 result.to_s)
    assert_fault_messages(["1st pend"], result.pendings)
    assert_true(test.interrupted?)
  end

  def test_pend_with_failure_in_block
    test = nil
    result = _run_test("test_pend_with_failure_in_block") {|t| test = t}
    assert_equal("1 tests, 1 assertions, 0 failures, 0 errors, 1 pendings, " \
                 "0 omissions, 0 notifications",
                 result.to_s)
    assert_fault_messages(["Wait a minute"], result.pendings)
    assert_false(test.interrupted?)
  end

  def test_pend_with_no_failure_in_block
    test = nil
    result = _run_test("test_pend_with_no_failure_in_block") {|t| test = t}
    assert_equal("1 tests, 1 assertions, 1 failures, 0 errors, 0 pendings, " \
                 "0 omissions, 0 notifications",
                 result.to_s)
    assert_fault_messages(["Pending block should not be passed: Wait a minute."],
                          result.failures)
    assert_true(test.interrupted?)
  end

  private
  def _run_test(name, &block)
    super(TestCase, name, &block)
  end
end