If it's not helpful, maybe you could clarify what you want to do. It
seems from your post that you don't want to be required to execute
Main_Site_Test to execute Similar_Test, but you also want to reuse
test_0002_login which is in Main_Site_Test.
If it's not helpful, maybe you could clarify what you want to do. It
seems from your post that you don't want to be required to execute
Main_Site_Test to execute Similar_Test, but you also want to reuse
test_0002_login which is in Main_Site_Test.- Hide quoted text -
Would using mixin instead inheritance work in your case?
Could you give me an example of where the module would be used and
what it would contain?
Aidy
We encountered a similar condition with our test framework. While the
Test::Unit framework provides the mechanism to run tests, we found that
there was a lot of duplication of code...particularly in the
setup/teardown methods.
Our approach used something like this (names changed to protect the
innocent)
common_testcase.rb
module MyNamespace
module TestCase
def setup
# Enter common setup code here
puts "Common setup code"
end
def teardown
# Enter common teardown code here
puts "Common teardown code"
end
def doWork
# Enter common worker code here
puts "Common worker method"
end
end # TestCase
end # MyNamespace
my_testcase.rb
class TC_MyTestCase < Test::Unit::TestCase
require 'common_testcase.rb'
include MyNameSpace::TestCase
# Test Case - Do the test
def test_doTest
doWork
end
end # TC_MyTestCase
By implementing the common functionality in a separate module, it can be
included in each of your test cases. Place the common code in the
module, and mixin with the test cases. Just don't place any 'test_*'
methods in the common code.