Manipulate output from test/unit methods?

C

Chris McMahon

When you use any of the test/unit methods, like "assert_equal", you
always get a nice output message like

1 tests, 2 assertions, 0 failures, 0 errors

or

<"CLARICE"> expected but was
<"JOHN">.
1 tests, 1 assertions, 1 failures, 0 errors

How can I manipulate that output message, for instance assign the whole
string from "<"CLARICE"> to "0 errors" to a variable?

It's not in $_ or $! or $stdout or $stdout, and I can't seem to assign
it to a variable. None of these work; the puts's are always "nil" or
something obscure from IO#:

a = assert_equal(x,y)
puts a

assert_equal(x,y)
puts $_

assert_equal(x,y)
puts $!

puts $stdout
puts $stdout
 
E

Eric Hodel

When you use any of the test/unit methods, like "assert_equal", you
always get a nice output message like

1 tests, 2 assertions, 0 failures, 0 errors

or

<"CLARICE"> expected but was
<"JOHN">.
1 tests, 1 assertions, 1 failures, 0 errors

How can I manipulate that output message, for instance assign the
whole
string from "<"CLARICE"> to "0 errors" to a variable?

Well... What are you trying to accomplish? ZenTest's unit_diff works
with output messages as a filter, so you just have to pipe your test/
unit output through it.
 
D

Damphyr

Eric said:
---

Well... What are you trying to accomplish? ZenTest's unit_diff works
with output messages as a filter, so you just have to pipe your
test/ unit output through it.
Well this is a related question on the output of unit tests:
Is there a way to suppress everything except the result of the tests?
I have lots of negative tests (where the error handling of my apps is
checked) and would like to shut off the exceptions and their messages on
a succesful negative test (this makes the logs of automated test runs a
lot lighter).
Cheers,
V.-

--
http://www.braveworld.net/riva

____________________________________________________________________
http://www.freemail.gr - äùñåÜí õðçñåóßá çëåêôñïíéêïý ôá÷õäñïìåßïõ.
http://www.freemail.gr - free email service for the Greek-speaking.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top