Test::Unit in 1.8

J

Joel VanderWerf

So far I've noticed two changes in the Test::Unit included with 1.8.
They've probably been in Test::Unit for I long time, but I'm just
encountering them now with 1.8, due to laziness.

First, you have to define #setup instead of #set_up. I guess I prefer
the new way (I remember a long discussion some time ago), but it might
be nice to get a warning that you have defined #set_up, and it will not
be called...

Second, you can no longer define a subclass of TestCase to be used as an
"abstract" base class of other test case classes. For example, the
following flunks, because BaseTest has no tests:

require 'test/unit'

class BaseTest < Test::Unit::TestCase
def do_foo_test
puts "testing foo"
end
end

class DerivedTest < BaseTest
def test_derived
do_foo_test
end
end

I've gotten around this by adding a dummy test method to my base class.
I could also have made it a mixin. It's just a minor annoyance.

Maybe it would be possible to have a class method of TestCase that marks
the class as "abstract"? E.g.,

class BaseTest < Test::Unit::TestCase
abstract_test_class
...
end

Hope this helps someone who's as slow to upgrade as me...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top