Pit Capitain
7/2/2005 5:55:00 AM
David Corbin schrieb:
> The problem I'm having, is if I have syntax errors, I still get a green bar
> (fewer tests are shown), and there is NO indication of syntax errors, if one
> of the required test files has syntax errors.
>
> Help me understand why the there's no trace of syntax error when the required
> file has one.
>
> def requireAllTests(pattern)
> Dir.glob(pattern).each do |file|
> require file
> end
> end
Hi David,
I haven't looked where this happens, but it seems that test/unit
discards those errors. When this happened to me, I simply catched the
load errors myself and reported them with puts.
You write that you get a green bar, so I assume you're running a
graphical frontend. In this case, I guess a simple puts wouldn't be
enough. You could try the following code, which creates a new TestCase
class for each load error in order to present them as a failing test:
def requireAllTests(pattern)
Dir.glob(pattern).each do |file|
begin
require file
rescue Exception => e
Class.new(Test::Unit::TestCase) do
define_method(:test_load) do ||
flunk("#{file}: #{e}")
end
public :test_load
end
end
end
end
Regards,
Pit