Forum: Ruby Redirecting TestRunner output from console to file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Vadim D. (Guest)
on 2009-05-06 15:45
Hi guys

I'm novice both in Ruby and test/unit, so keep it in mind.

I have the following  question:
How can I redirect the Test Runner output from console to some file or
string variable?

E.g.
I run tests with the following arguments

io=File.new('results.txt', 'w')
tr=Test::Unit::UI::Console::TestRunner.new(Testcase,"VERBOSE",io)

So Test IO should write to io variable but indeed it doesn't contain any
test results.
Ruby global variable $stdout is also empty. So it seems strange for me.

If you know what's wrong with my code and assumptions or some other way
how to get test results please answear.

Thank you in advance.
Ryan D. (Guest)
on 2009-05-06 22:03
(Received via mailing list)
On May 6, 2009, at 04:45 , Vadim Dobrovolsky wrote:

>
> io=File.new('results.txt', 'w')
> tr=Test::Unit::UI::Console::TestRunner.new(Testcase,"VERBOSE",io)

Do the simplest thing that could possibly work:

% ruby -Ilib test/test_blah.rb > results.txt
This topic is locked and can not be replied to.