[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Test::Unit need help with assert

Shayne Bateman

10/26/2006 9:09:00 PM

Hi,
I'm new to Ruby but have has some success bending it to my will. I am
using the Test::Unit framework but it doesn't quite fit my needs. I need
to report the number of asserts() that pass and the number that fail.
Also, I need failed asserts to not stop the program flow. Am I using
the wrong test framework or can I easily bend Test::Unit to my needs?
Thanks in advance!
Shayne

--
Posted via http://www.ruby-....

4 Answers

Shayne Bateman

10/26/2006 9:23:00 PM

0

Alright, I'm not too bright sometimes :)

I just realized the asserts are counted every time it runs and the final
output tallies them all up.

So, the real question now is, how do I prevent a failed assert from
stopping the testcase it is in?

Thanks

--
Posted via http://www.ruby-....

Timothy Goddard

10/26/2006 9:40:00 PM

0

Shayne Bateman wrote:
> Alright, I'm not too bright sometimes :)
>
> I just realized the asserts are counted every time it runs and the final
> output tallies them all up.
>
> So, the real question now is, how do I prevent a failed assert from
> stopping the testcase it is in?
>
> Thanks
>
> --
> Posted via http://www.ruby-....

Unit tests aren't meant for counting how many assertions fail, they're
meant to indicate where problems are so they can be fixed. You may want
to divide your tests up further if you need fine grained details. If
you absolutely have to do all tests you may want to do something like
this:

....
def test_something
failed = []
failed << :first_test unless condition1
failed << :second_test unless condition2
assert failed == [], "#{failed.length} tests failed:
#{failed.map{|e| e.to_s}.join(', ')}"
end
....

If you're trying to bend Ruby to your will then you're thinking wrong.

Pit Capitain

10/27/2006 7:09:00 AM

0

Shayne Bateman schrieb:
> Also, I need failed asserts to not stop the program flow. Am I using
> the wrong test framework or can I easily bend Test::Unit to my needs?

Shayne, maybe this gives you some ideas:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...

Regards,
Pit

Shayne Bateman

10/27/2006 4:18:00 PM

0

Pit Capitain wrote:
> Shayne, maybe this gives you some ideas:
>
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...
>
> Regards,
> Pit

That was right on the money. Thanks

--
Posted via http://www.ruby-....