Test::Unit need help with assert

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-forum.com/.

Alright, I'm not too bright sometimes :slight_smile:

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-forum.com/.

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-talk/138320

Regards,
Pit

Shayne Bateman wrote:

Alright, I'm not too bright sometimes :slight_smile:

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-forum.com/\.

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 wrote:

Shayne, maybe this gives you some ideas:

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

Regards,
Pit

That was right on the money. Thanks

···

--
Posted via http://www.ruby-forum.com/\.