class Test::Unit::TestTestCase
Public Class Methods
new(test)
click to toggle source
Calls superclass method
Test::Unit::TestCase::new
# File test-unit-3.3.4/test/test-test-case.rb, line 263 def initialize(test) super(test) @setup_called = false @teardown_called = false end
Public Instance Methods
cruby?()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 170 def cruby? (not jruby?) and (not rubinius?) end
dont_run()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 238 def dont_run assert_block {true} end
jruby?()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 162 def jruby? defined?(JRUBY_VERSION) end
jruby_backtrace_entry?(entry)
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 56 def jruby_backtrace_entry?(entry) entry.start_with?("org/jruby/") end
my_test_method()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 501 def my_test_method end
nested()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 41 def nested assert_block("nested") do false end end
normalize_location(location)
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 64 def normalize_location(location) filtered_location = location.reject do |entry| jruby_backtrace_entry?(entry) or rubinius_backtrace_entry?(entry) end filtered_location.collect do |entry| entry.sub(/:\d+:/, ":0:") end end
return_passed?()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 46 def return_passed? return passed? end
rubinius?()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 166 def rubinius? false # TODO end
rubinius_backtrace_entry?(entry)
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 60 def rubinius_backtrace_entry?(entry) entry.start_with?("kernel/") end
setup()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 28 def setup @tc_failure_error = Class.new(TestCase) do def test_failure assert_block("failure") do false end end def test_error 1 / 0 end def test_nested_failure nested end def nested assert_block("nested") do false end end def return_passed? return passed? end end def @tc_failure_error.name "TC_FailureError" end end
teardown()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 271 def teardown @teardown_called = true end
test()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 244 def test assert_block {true} end
test_1()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 324 def test_1 end
test_2()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 326 def test_2 end
test_a()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 464 def test_a end
test_add_error()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 174 def test_add_error test_case = @tc_failure_error.new(:test_error) assert do test_case.passed? end result = TestResult.new faults = [] result.add_listener(TestResult::FAULT) do |fault| faults << fault end test_case.run(result) do end fault_details = faults.collect do |fault| { :class => fault.class, :message => fault.message, :test_name => fault.test_name, :location => normalize_location(fault.location), } end location = [] location << "#{__FILE__}:0:in `/'" if cruby? location << "#{__FILE__}:0:in `test_error'" location << "#{__FILE__}:0:in `#{__method__}'" assert_equal([ { :class => Error, :message => "ZeroDivisionError: divided by 0", :test_name => "test_error(TC_FailureError)", :location => location, }, ], fault_details) assert do not test_case.passed? end end
test_add_failed_assertion()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 74 def test_add_failed_assertion test_case = @tc_failure_error.new(:test_failure) assert do test_case.passed? end result = TestResult.new faults = [] result.add_listener(TestResult::FAULT) do |fault| faults << fault end progress = [] test_case.run(result) do |*arguments| progress << arguments end fault_details = faults.collect do |fault| { :class => fault.class, :message => fault.message, :test_name => fault.test_name, :location => normalize_location(fault.location), } end assert_equal([ { :class => Failure, :message => "failure", :test_name => "test_failure(TC_FailureError)", :location => [ "#{__FILE__}:0:in `test_failure'", "#{__FILE__}:0:in `#{__method__}'", ], }, ], fault_details) assert do not test_case.passed? end assert_equal([ [TestCase::STARTED, test_case.name], [TestCase::STARTED_OBJECT, test_case], [TestCase::FINISHED, test_case.name], [TestCase::FINISHED_OBJECT, test_case], ], progress) end
test_add_failure_nested()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 122 def test_add_failure_nested test_case = @tc_failure_error.new(:test_nested_failure) assert do test_case.passed? end result = TestResult.new faults = [] result.add_listener(TestResult::FAULT) do |fault| faults << fault end test_case.run(result) do end fault_details = faults.collect do |fault| { :class => fault.class, :message => fault.message, :test_name => fault.test_name, :location => normalize_location(fault.location), } end assert_equal([ { :class => Failure, :message => "nested", :test_name => "test_nested_failure(TC_FailureError)", :location => [ "#{__FILE__}:0:in `nested'", "#{__FILE__}:0:in `test_nested_failure'", "#{__FILE__}:0:in `#{__method__}'", ], }, ], fault_details) assert do not test_case.passed? end end
test_assertion_failed_not_called()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 306 def test_assertion_failed_not_called tc = Class.new(TestCase) do def test_thing raise AssertionFailedError.new end end suite = tc.suite check("Should have one test", suite.size == 1) result = TestResult.new suite.run(result) {} check("Should have had one test run", result.run_count == 1) check("Should have had one assertion failure", result.failure_count == 1) check("Should not have any assertion errors but had #{result.error_count}", result.error_count == 0) end
test_creation()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 13 def test_creation test_case = Class.new(TestCase) do def test_with_arguments(arg1, arg2) end end test = test_case.new(:test_with_arguments) check("Should have caught an invalid test when there are arguments", !test.valid?) test = test_case.new(:non_existent_test) check("Should have caught an invalid test when the method does not exist", !test.valid?) end
test_data_driven_test()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 533 def test_data_driven_test test_case = Class.new(TestCase) do def test_with_data(data) end end test = test_case.new("test_with_data") assert_not_predicate(test, :valid?) test.assign_test_data("label1", :test_data1) assert_predicate(test, :valid?) end
test_data_driven_test_without_parameter()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 545 def test_data_driven_test_without_parameter test_case = Class.new(TestCase) do data("label" => "value") def test_without_parameter assert_equal("value", data) end end suite = test_case.suite assert_equal(["test_without_parameter"], suite.tests.collect {|test| test.method_name}) result = TestResult.new suite.run(result) {} assert_equal("1 tests, 1 assertions, 0 failures, " + "0 errors, 0 pendings, 0 omissions, 0 notifications", result.summary) end
test_declarative_style()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 473 def test_declarative_style test_case = Class.new(Test::Unit::TestCase) do test "declarative style test definition" do end test "include parenthesis" do end test "1 + 2 = 3" do end end test_case.test_order = :defined assert_equal(["test: declarative style test definition", "test: include parenthesis", "test: 1 + 2 = 3"], test_case.suite.tests.collect {|test| test.method_name}) assert_equal(["declarative style test definition", "include parenthesis", "1 + 2 = 3"], test_case.suite.tests.collect {|test| test.description}) end
test_defined_order()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 456 def test_defined_order test_case = Class.new(Test::Unit::TestCase) do def test_z end def test_1 end def test_a end end test_case.test_order = :defined assert_equal(["test_z", "test_1", "test_a"], test_case.suite.tests.collect {|test| test.method_name}) end
test_dont_run(argument)
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 241 def test_dont_run(argument) assert_block {true} end
test_equality()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 322 def test_equality tc1 = Class.new(TestCase) do def test_1 end def test_2 end end tc2 = Class.new(TestCase) do def test_1 end end test1 = tc1.new('test_1') test2 = tc1.new('test_1') check("Should be equal", test1 == test2) check("Should be equal", test2 == test1) test1 = tc1.new('test_2') check("Should not be equal", test1 != test2) check("Should not be equal", test2 != test1) test2 = tc1.new('test_2') check("Should be equal", test1 == test2) check("Should be equal", test2 == test1) test1 = tc1.new('test_1') test2 = tc2.new('test_1') check("Should not be equal", test1 != test2) check("Should not be equal", test2 != test1) check("Should not be equal", test1 != Object.new) check("Should not be equal", Object.new != test1) end
test_error()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 35 def test_error 1 / 0 end
test_fail()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 232 def test_fail assert_block {false} end
test_failure()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 30 def test_failure assert_block("failure") do false end end
test_inherited_test_should_be_ignored()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 411 def test_inherited_test_should_be_ignored test_case = Class.new(TestCase) do def test_nothing end end sub_test_case = Class.new(test_case) do def test_fail flunk end end test = test_case.new("test_nothing") assert_predicate(test, :valid?) test = sub_test_case.new("test_fail") assert_predicate(test, :valid?) test = sub_test_case.new("test_nothing") assert_not_predicate(test, :valid?) end
test_interrupted()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 392 def test_interrupted test_case = Class.new(TestCase) do def test_fail flunk end def test_nothing end end failed_test = test_case.new(:test_fail) failed_test.run(TestResult.new) {} check("Should be interrupted", failed_test.interrupted?) success_test = test_case.new(:test_nothing) success_test.run(TestResult.new) {} check("Should not be interrupted", !success_test.interrupted?) end
test_mixin_test_should_not_be_ignored()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 433 def test_mixin_test_should_not_be_ignored test_module = Module.new do def test_nothing end end test_case = Class.new(Test::Unit::TestCase) do include test_module def test_fail flunk end end assert_nothing_thrown do test_case.new("test_nothing") end assert_nothing_thrown do test_case.new("test_fail") end end
test_name()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 515 def test_name end
test_nested_failure()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 38 def test_nested_failure nested end
test_no_tests()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 214 def test_no_tests suite = TestCase.suite check("Should have a test suite", suite.instance_of?(TestSuite)) check("Should have one test", suite.size == 1) check("Should have the default test", suite.tests.first.name == "default_test(Test::Unit::TestCase)") result = TestResult.new suite.run(result) {} check("Should have had one test run", result.run_count == 1) check("Should have had one test failure", result.failure_count == 1) check("Should have had no errors", result.error_count == 0) end
test_nothing()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 398 def test_nothing end
test_raise_interrupt()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 359 def test_raise_interrupt raise Interrupt, "from test" end
test_raise_timeout_error()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 375 def test_raise_timeout_error require "timeout" raise Timeout::Error end
test_re_raise_exception()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 357 def test_re_raise_exception test_case = Class.new(TestCase) do def test_raise_interrupt raise Interrupt, "from test" end end test = test_case.new("test_raise_interrupt") begin test.run(TestResult.new) {} check("Should not be reached", false) rescue Exception check("Interrupt exception should be re-raised", $!.class == Interrupt) end end
test_redefine_method()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 511 def test_redefine_method test_case = Class.new(Test::Unit::TestCase) do self.test_order = :alphabetic def test_name end alias_method :test_name2, :test_name def test_name end end suite = test_case.suite assert_equal(["test_name", "test_name2"], suite.tests.collect {|test| test.method_name}) result = TestResult.new suite.run(result) {} assert_equal("2 tests, 0 assertions, 0 failures, " + "0 errors, 0 pendings, 0 omissions, 1 notifications", result.summary) end
test_setup_teardown()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 260 def test_setup_teardown tc = Class.new(TestCase) do attr_reader(:setup_called, :teardown_called) def initialize(test) super(test) @setup_called = false @teardown_called = false end def setup @setup_called = true end def teardown @teardown_called = true end def test_succeed assert_block {true} end def test_fail assert_block {false} end def test_error raise "Error!" end end result = TestResult.new test = tc.new(:test_succeed) test.run(result) {} check("Should have called setup the correct number of times", test.setup_called) check("Should have called teardown the correct number of times", test.teardown_called) test = tc.new(:test_fail) test.run(result) {} check("Should have called setup the correct number of times", test.setup_called) check("Should have called teardown the correct number of times", test.teardown_called) test = tc.new(:test_error) test.run(result) {} check("Should have called setup the correct number of times", test.setup_called) check("Should have called teardown the correct number of times", test.teardown_called) check("Should have had two test runs", result.run_count == 3) check("Should have had a test failure", result.failure_count == 1) check("Should have had a test error", result.error_count == 1) end
test_succeed()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 229 def test_succeed assert_block {true} end
test_suite()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 227 def test_suite tc = Class.new(TestCase) do def test_succeed assert_block {true} end def test_fail assert_block {false} end def test_error 1/0 end def dont_run assert_block {true} end def test_dont_run(argument) assert_block {true} end def test assert_block {true} end end suite = tc.suite check("Should have a test suite", suite.instance_of?(TestSuite)) check("Should have three tests", suite.size == 3) result = TestResult.new suite.run(result) {} check("Should have had three test runs", result.run_count == 3) check("Should have had one test failure", result.failure_count == 1) check("Should have had one test error", result.error_count == 1) end
test_test_mark()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 498 def test_test_mark test_case = Class.new(Test::Unit::TestCase) do test def my_test_method end end test_case.test_order = :defined assert_equal(["my_test_method"], test_case.suite.tests.collect {|test| test.method_name}) end
test_thing()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 308 def test_thing raise AssertionFailedError.new end
test_timeout_error()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 373 def test_timeout_error test_case = Class.new(TestCase) do def test_raise_timeout_error require "timeout" raise Timeout::Error end end test_suite = test_case.suite result = TestResult.new begin test_suite.run(result) {} check("Timeout::Error should be handled as error", result.error_count == 1) rescue Exception check("Timeout::Error should not be passed through: #{$!}", false) end end
test_with_arguments(arg1, arg2)
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 15 def test_with_arguments(arg1, arg2) end
test_with_data(data)
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 535 def test_with_data(data) end
test_without_parameter()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 548 def test_without_parameter assert_equal("value", data) end
test_z()
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 458 def test_z end
Private Instance Methods
check(message, passed)
click to toggle source
# File test-unit-3.3.4/test/test-test-case.rb, line 564 def check(message, passed) add_assertion raise AssertionFailedError.new(message) unless passed end