On 3/23/06, Padhma N <[EMAIL PROTECTED]> wrote: > > Hi, > > I have 2 questions. > > (1) I would like to send the results of my test suite to a .txt file and > also want the results to be seen on the console. How do I do that? > I know that I can use the following command in the command prompt- > function1.rb > results.txt > > But I want something more like,the program itself directing its each output > to both the console and the results.txt file. > I tried f.syswrite but that seems inefficient as I have to use f.syswrite at > all places I use puts statement. Is there a better way to do this?
Not sure of a way to do your question (2). However, as for question (1) I was sort of able to split output from running a suite to $stdout and a file, by passing an io handle into TestRunner.new(), then using << to send the test run output to $stdout as shown in this example: ==================================================== require 'test/unit/testsuite' require 'test/unit/ui/console/testrunner' outputFileName = 'suite.log' outputFileHandle = File.new(outputFileName, "w+") ...require test cases and create suite here... # create new runner and start suite: $stdout << Test::Unit::UI::Console::TestRunner.new(TS_MyTests, output_level=2, io=outputFileHandle).start ==================================================== However, while this puts all the runner output into 'suite.log', only the final summary line (with the number of tests/assertions/failures/errors) is displayed on the console. So what I currently do in this case is just 'tail -f suite.log' using Cygwin's tail util to get up-to-the-minute status as the suite runs. :) However, I'm sure there's some way to direct the script to send all the output to $stdout as well as the suite logfile. I just haven't run across it so far... Thanks Bill _______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
