Inheriting tests in testcases

I’m using Test::Rails from ZenTest.
I did an abstract(?) class that inherits from Test::Rails::TestCase and
I wanted to define some general test there to be inherited by my
testcases.

The problem is that when I run my testcase the tests defined in the
avstract class are executed twice: first for the class inheriting from
it and then again for the abstract class.

To be more clear:

MyTestCase < MyAbstracyClass < Test::Rails::TestCase

Supposing there is one test defined in MyTestCase and two defined in
MyAbstractClass the test executed will be 5.

How can I skip the tests in the abstract class?
Till now I resolved setting the following code at the beginning of each
test:
return if self.class == MyAbstracyClass
…but the test are still be counted…

Any idea?

On 7 Nov 2007, at 10:38, Emanuele R. wrote:

return if self.class == MyAbstracyClass
…but the test are still be counted…

Any idea?
I don’t know how zen test differs from the Test::Unit stuff that comes
as standard with ruby, but
we had a similar situation with that and ended up putting the common
stuff in a module which we included where appropriate.

Fred

On Nov 7, 2007 9:46 PM, Frederick C. [email protected]
wrote:

How can I skip the tests in the abstract class?
stuff in a module which we included where appropriate.
I’d use mixins too, but if it’s too late:

require ‘active_support’
require ‘test/unit’

class << Test::Unit::TestCase
def abstract
@abstract = true
end

def suite_with_abstract
if @abstract
Test::Unit::TestSuite.new
else
suite_without_abstract
end
end
alias_method_chain :suite, :abstract
end

class AbstractTests < Test::Unit::TestCase
abstract

def test_a
assert true
end
end

class RealTests < AbstractTests
end

class MoreRealTests < AbstractTests
end

It works indeed,
thank you very much George.

Sounds great if it works, but it is not clear to me where to put the
following code:

require ‘active_support’
require ‘test/unit’

class << Test::Unit::TestCase
def abstract
@abstract = true
end

def suite_with_abstract
if @abstract
Test::Unit::TestSuite.new
else
suite_without_abstract
end
end
alias_method_chain :suite, :abstract
end