Jeff Fry wrote:
> def test_random_stuff
>   1.upto(100) do |stuff|  
>     #each test is somewhat randomized
>     assert_no_match(certain error)
>   end #do
> end #test_random_stuff
>
> current behavior:
> test/unit exits the test case as soon as an assertion fails.
>
> what I'd /like /to end up with is a test that passes or fails and then 
> runs again either way.
> It might generate a list of pass/fail results from my random tests, 
> something like:
> dataset 1 pass
> dataset 2 pass
> dataset 3 fail
> dataset 4 pass
> dataset 5 fail
> ...
> dataset 100 pass
>
>
> How would you suggest going about this?
There are two ways to do this.

1. Use verify instead of assert.

I've recently released a verify method, which is backwards compatable 
with 1.4. This works like assert, except that it does not abort a test 
case. However, using it will only result in a list of failures, not passes.

2. Dynamically create your test case methods.

What you will have to do is on the first pass (at load time), generate 
all your test case methods. These will then be executed. This is more 
complex, but will give you the results you request.

class MyTest < Test::Unit::TestCase
  100.times do | count |
      method_name = :"test_#{count}"
      define_method method_name do
        #each test is somewhat randomized
        assert_no_match(certain error)
      end
  end
end 
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to