[Wtr-general] Failing a test without aborting it

Bret Pettichord bret at pettichord.com
Wed Aug 23 16:21:25 EDT 2006


A frequently asked question has been how do you cause a test 
verification to fail the test without immediately aborting it as well. 
Frequent replies have been to wrap assertions with rescue blocks, which 
raises all kinds of other problems. Here is a much better solution.

  def verify boolean, message = 'verify failed.'
    add_assertion
    add_failure message, caller unless boolean
  end

Define this method in your test case class, and then use it instead of 
assert.

Bret




More information about the Wtr-general mailing list