From: Martin Hart Date: 2003-01-11T02:05:35+09:00 Subject: Re: iterating in a test On 1/10/03, 4:51:02 PM, Paul Brannan wrote regarding Re: iterating in a test: > This alone does not solve the whole problem; f(i) could raise an > exception, and if it does I do not know what i is. Ok, this is messy, ugly, and probably not what you want :-) [martin@dorfl martin]$ cat test.rb require 'test/unit' def f(i) raise "anException" if i==1 i end class TestX < Test::Unit::TestCase def testF 10.times { |i| assert_nothing_raised("i was #{i}") { assert_equal(0, f(i), "i was #{i}") } } end end As you can see, the problem now is that if the assert_equal fails, we actually get an "Exception raised" error. However, you do get to see what i is :-) Cheers, Martin