The problem is that, as far as I can tell, Test::Unit keeps track of which classes inherit from Test::Unit::TestCase , and, as a result, will only run tests from classes that directly inherit from it.
The way around this is to create a module with the tests you need, and then include this module in classes that come from Test::Unit::TestCase .
require 'test/unit' module TestsToInclude def test_name assert(self.class.name.start_with?("Concrete")) end end class Concrete1 < Test::Unit::TestCase include TestsToInclude def test_something_bad assert(false) end end class Concrete2 < Test::Unit::TestCase include TestsToInclude def test_something_good assert(true) end end
Output:
Loaded suite a
Started
.F ..
Finished in 0.027873 seconds.
1) Failure:
test_something_bad (Concrete1) [a.rb: 13]:
<false> is not true.
4 tests, 4 assertions, 1 failures, 0 errors
shell returned 1
source share