F
Feng Tien
I've been learning Ruby the last couple weeks and trying to figure how
to Unit Test
I wrote a method that outputs a few lines of text.
How do I write an assertion so it tests if, say the last line printed is
equal to the expected? Lasts just say the program asks for 2 numbers,
and outputs all the number from the lowest to the highest.
I tried using:
assert_equal '11' , fizzbang(10,100)
but that does not work, because puts methods outputs are nil.
how do you match puts? is there a different assertion you have to use?
or is there no way to do this with Test::Unit assertion, will I have to
extract the text somehow from the method? How do I do that?
Thanks!
to Unit Test
I wrote a method that outputs a few lines of text.
How do I write an assertion so it tests if, say the last line printed is
equal to the expected? Lasts just say the program asks for 2 numbers,
and outputs all the number from the lowest to the highest.
I tried using:
assert_equal '11' , fizzbang(10,100)
but that does not work, because puts methods outputs are nil.
how do you match puts? is there a different assertion you have to use?
or is there no way to do this with Test::Unit assertion, will I have to
extract the text somehow from the method? How do I do that?
Thanks!