From: Phlip Date: 2006-09-07T10:05:21+09:00 Subject: Abstract Tests vs AutoRunner Rubies: I'm trying to get some elaborate test suites working via the hidden call to AutoRunner. Because I can't declare which suites to run, the system tests anything that derives from TestCase. I want to do this: class AbstractSuite < Test::Unit::TestCase def test_foo() p derive() end end class ConcreteSuiteA < AbstractSuite def derive() return 'like this' end end class ConcreteSuiteB < AbstractSuite def derive() return 'like that' end end That's the skeleton of the Abstract Test pattern, which is a major Good Thing. It prevents us from writing zillions of duplicate test cases with minimal differences between each one. For example, my derive() could return an object that must pass the same tests as another object, obeying Liskov Substitution Principle. However, I can't do it like that, because AutoRunner hoovers up every class derived from TestCase, and runs all of them as suites. I predictably get "test_foo(AbstractSuite): NoMethodError: undefined method `derive'" The ugly fix is this: class ConcreteSuiteA < Test::Unit::TestCase def test_foo() p derive() end def derive() return 'like this' end end class ConcreteSuiteB < ConcreteSuiteA def derive() return 'like that' end end That works, but it's "not OO". ConcreteSuiteB is not truly a derived version of ConcreteSuiteA. So I'm asking this question because I don't understand mixins, or AutoRunner, enough to fix this. Could a mixin grant test cases to two concrete classes? Alternately, does AutoRunner have a feature to bump a suite from its list? -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!