Forum: Ruby on Rails unit tests for sub-classes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ddd11872984864786c14992b99ab4d2d?d=identicon&s=25 Alan Bullock (Guest)
on 2006-03-18 18:41
(Received via mailing list)
I posted about this a couple of weeks ago but didn't get much response
so I
thought I'd try again.

when you create a subclass of Test::Unit::TestCase, e.g. PersonTest (for
model Person), the tests in that class get run automatically whenever
the
file is loaded. so far so good.

Let's say I then create a Manager class which subclasses Person. I want
ManagerTest to extend PersonTest. However, because of the automatic
running
I mentioned previously, if you try to load manager_test.rb, you end up
running both PersonTest and ManagerTest. This may not sound like a big
problem but I have 3 levels of subclasses on about 6 core classes, so
you
can imagine how long 'rake test_units' takes to run!

The only way round it that I've found is to create a subclass of
TestCase
for each model which contains test for the functionality in the parent
class
and it's derived class, but that totally violates the DRY principle.
IMHO
the TestCase for the parent should test the parent functionality, and
subclassed TestCases should test the functionality of the subclasses.

this problem is only going to get worse as I add more parent and
sub-classes, so could someone please save what little hair I have left
and
suggest a workaround?

thanks for reading
al
This topic is locked and can not be replied to.