From: dblack@... Date: 2003-09-15T21:56:48+09:00 Subject: Re: Test::Unit -- multiple errors in test method ??? Hi -- On Mon, 15 Sep 2003, Johan Holmberg wrote: > - I have tried to write some table driven tests. How should I do > this ? Currently I tried something in the following style: > > ... > @@data = [ > [2, 1, 1], > [5, 2, 2], # should fail > [7, 2, 5], > [8, 3, 4], # should fail > ] > > def test_b > for facit, aa, bb in @@data > assert_equal facit, aa + bb > end > end > ... > > Here I have several tests that are not "increasing". > (just before I post this I saw David Alan Blacks answer mentioning > Test::Unit::AssertionFailedError. Should I catch that ? ) You could turn the whole thing on its head, so to speak: require 'test/unit' class TestMe < Test::Unit::TestCase def setup @@data = [ [2, 1, 1], [5, 2, 2], # should fail [7, 2, 5], [8, 3, 4], # should fail ] end def test_addition wrong = @@data.find_all {|d| d[0] != d[1] + d[2]} assert(wrong.empty?, "These failed: #{wrong.inspect}") end end (give or take some granularity in the error-reporting, etc.) David -- David Alan Black home: dblack@superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav