Test::Unit bug (maybe?)

Given the following unit tests …

– Unit Tests --------------------------------
class TestOne < Test::Unit::TestCase
def test_ok
assert true, "this will pass"
end
end

class TestTwo < Test::Unit::TestCase
include UndefinedModule

def test_also_ok
assert true, "This will be ignored"
end
end
– END ---------------------------------------

Running them gives …

– UNIT TEST OUTPUT --------------------------
traken$ ruby testbug.rb
testbug.rb:13: uninitialized constant UndefinedModule at TestTwo
(NameError)
Loaded suite testbug
Started

Finished in 0.004499 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
– END ---------------------------------------

Granted, there is a NameError in the output of the testcase, but the
final line (0 failures, 0 errors) gives no hint of that.

Is is possible for Unit::Test to trap that error and report it in the
summary line? Or am I asking for the impossible?

BTW, great job on Test::Unit … I use it ALL the time.

···


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)

Given the following unit tests …

– Unit Tests --------------------------------
class TestOne < Test::Unit::TestCase
def test_ok
assert true, “this will pass”
end
end

class TestTwo < Test::Unit::TestCase
include UndefinedModule

def test_also_ok
assert true, “This will be ignored”
end
end
– END ---------------------------------------

Running them gives …

– UNIT TEST OUTPUT --------------------------
traken$ ruby testbug.rb
testbug.rb:13: uninitialized constant UndefinedModule at TestTwo
(NameError)
Loaded suite testbug
Started

Finished in 0.004499 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
– END ---------------------------------------

Granted, there is a NameError in the output of the testcase,
but the final line (0 failures, 0 errors) gives no hint of that.

Is is possible for Unit::Test to trap that error and report
it in the summary line? Or am I asking for the impossible?

I agree this is somewhat disconcerting, but I don’t know of a good way
of fixing it. If there’s a good, clean solution to trap errors like
this, then I’m all ears… otherwise, I don’t think there’s much I can
do. Sorry :frowning:

BTW, great job on Test::Unit … I use it ALL the time.

Thank you for evangelizing unit testing (I loved your test first
write-up a few days ago) - the world needs more unit testers :slight_smile:

Nathaniel

<:((><

···

Jim Weirich [mailto:jim@mail.one.net] wrote:

RoleModel Software, Inc.
EQUIP VI