Require problem with syntax errors

I have written a little "test suite" for my use in developing a rails
application (I know about "rake test_units", but that won't work in my IDE of
choice). So, if I run unitTest.rb, all my tests run.

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.

Thanks
David

-- begin unitTestSuite.rb--
require "test_helper"
require "test_builder"

requireAllTests("test/unit/**/*.rb")

--end--
--begin test_builder.rb--
def requireAllTests(pattern)
   Dir.glob(pattern).each do |file|
     require file
   end
end

···

----

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

There don't seem to be any errors raised. I tried the puts, and I do have a
console window, but nothing shows up.

I tried your example too, and get nothing.

David

···

On Saturday 02 July 2005 01:54 am, Pit Capitain wrote:

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.

David Corbin schrieb:

There don't seem to be any errors raised. I tried the puts, and I do have a console window, but nothing shows up.

I tried your example too, and get nothing.

Weird. If you want, you can send your files to my mail address and I'll have a short look.

Regards,
Pit