From: Johan Holmberg Date: 2003-09-15T23:08:30+09:00 Subject: Re: Test::Unit -- multiple errors in test method ??? On Mon, 15 Sep 2003, ts wrote: > > >>>>> "J" == Johan Holmberg writes: > > J> No, not really. > J> When I wrote "should fail" I just meant that I had written a line in > J> the table that *as it stands* give an error. > > Then this ? > Yes ! Thanks, for the example code. It seems to solve my problems in the case where I want to use table-driven tests, and where each test (i.e. line in the table) is independent of the others. /Johan Holmberg > svg% cat b.rb > #!/usr/bin/ruby > require 'test/unit' > > class TC_example < Test::Unit::TestCase > > @@data = [ > [2, 1, 1], > [5, 2, 2], # should fail > [7, 2, 5], > [8, 3, 7], # should fail > ] > > def test_a > error = [] > for facit, aa, bb in @@data > begin > assert_equal(facit, aa + bb) > rescue Exception > error << $! > end > end > error.each {|e| add_failure(e.message, e.backtrace) } > end > end > > svg% > > svg% b.rb > Loaded suite ./b > Started > FF > Finished in 0.002194 seconds. > > 1) Failure!!! > test_a(TC_example) [./b.rb:17]: > <5> expected but was > <4> > > 2) Failure!!! > test_a(TC_example) [./b.rb:17]: > <8> expected but was > <10> > > 1 tests, 4 assertions, 2 failures, 0 errors > svg% > > > Guy Decoux > >