From: Morton Goldberg Date: 2007-11-02T13:20:51+09:00 Subject: Re: assertion loop in test/unit? On Nov 1, 2007, at 9:17 PM, Todd A. Jacobs wrote: > In the following snippet, the first two fields exist, the remaining do > not. However, the test correctly tells me that replyaddr is > missing, but > never processes the last two items in the list: > > def test_fields_exist > @fields = ['jobid', 'company', 'replyaddr', 'SEEKER_CC', > 'RESUME_FILE'] > @fields.each do |field| > assert(@reply_form.has_field?(field), "Field missing: # > {field}") > end > end > > Why is that? AFAIK the Test::Unit framework always terminates a test method at the first failure. To get what I think you are looking for, you might write something like: def test_fields_present ['jobid', 'company'].each do |field| assert(@reply_form.has_field?(field), "Field missing: #{field}") end end def test_fields_missing ['replyaddr', 'SEEKER_CC', 'RESUME_FILE'].each do |field| assert(not @reply_form.has_field?(field), "Field present: # {field}") end end Regards, Morton