D
David Solis
Hello,
I'm having difficulty understanding inheritance in this case. In the
program below, I'm inheriting from <Test::Unit::TestCase. I also want my
other class in this program to inherit from <Test::Unit::TestCase. My
goal is to be able to make assertions in both classes.
If a run the program as written below, it works.
require 'test/unit'
require 'test/unit/ui/console/testrunner'
class TC_MyTest < Test::Unit::TestCase
def test_myMethod
puts 'test 1'
assert(true, 'test 1')
@test = TC_MyClass.new()
@test_new = @test.test_myTestCase
end
End
class TC_MyClass
def initialize
end
def test_myTestCase
puts 'test 2'
#assert(true, 'test 2')
puts 'test 3'
puts 'test 4'
end
end
But if try to do this, I get an error:
class TC_MyTest < Test::Unit::TestCase
def test_myMethod
puts 'test 1'
assert(true, 'test 1')
@test = TC_MyClass.new()
@test_new = @test.test_myTestCase
end
End
class TC_MyClass < Test::Unit::TestCase
def initialize
end
def test_myTestCase
puts 'test 2'
assert(true, 'test 2')
puts 'test 3'
puts 'test 4'
end
end
I'm having difficulty understanding inheritance in this case. In the
program below, I'm inheriting from <Test::Unit::TestCase. I also want my
other class in this program to inherit from <Test::Unit::TestCase. My
goal is to be able to make assertions in both classes.
If a run the program as written below, it works.
require 'test/unit'
require 'test/unit/ui/console/testrunner'
class TC_MyTest < Test::Unit::TestCase
def test_myMethod
puts 'test 1'
assert(true, 'test 1')
@test = TC_MyClass.new()
@test_new = @test.test_myTestCase
end
End
class TC_MyClass
def initialize
end
def test_myTestCase
puts 'test 2'
#assert(true, 'test 2')
puts 'test 3'
puts 'test 4'
end
end
But if try to do this, I get an error:
class TC_MyTest < Test::Unit::TestCase
def test_myMethod
puts 'test 1'
assert(true, 'test 1')
@test = TC_MyClass.new()
@test_new = @test.test_myTestCase
end
End
class TC_MyClass < Test::Unit::TestCase
def initialize
end
def test_myTestCase
puts 'test 2'
assert(true, 'test 2')
puts 'test 3'
puts 'test 4'
end
end