Hi all,

Ruby 1.6.8
TestUnit 0.1.8

I'm having a bit of difficulty with testunit in conjunction with
$DEBUG.  It just so happens that I want to run some tests with the
$DEBUG flag set to true.  So, let's say I have a class Foo:

# foo.rb
class Foo
   private_class_method :new
   @@foo = nil
   def Foo.create
      @@foo = new unless @@foo
      @@foo
   end
end

And a test file:

# tc_foo.rb
require "test/unit"
require "foo"
class TC_Foo < Test::Unit::TestCase
   def setup
      $DEBUG = true
   end
   def test_no_new
      assert_raises(NameError){ f = Foo.new }
   end
end

This runs ok, but I get some unwanted junk to STDERR:

>ruby tc_foo.rb 
Loaded suite tc_foo
Started
Exception `NameError' at tc_foo.rb:8 - private method `new' called for
Foo:Class -> I don't want this
..
Finished in 0.005636 seconds.
1 tests, 1 assertions, 0 failures, 0 errors

Trying to do something like STDERR.close won't help, because then you
can end up with something like:

IOError: closed stream
        foo.rb:15:in `close'
        foo.rb:15:in `setup'
        foo.rb:2

Is there a proper way to prevent the output to STDERR in testunit?  Keep
in mind that I would like a solution that works on MS Windows, as well
as *nix (so, no redirecting to /dev/null).

Regards,

Dan