Forum: Ruby on Rails Unit Tests Behavior

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bob S. (Guest)
on 2006-01-28 08:47
(Received via mailing list)

Working on unit tests and I have a few cascade delete constraints I am

The unit tests stop at the first assert_raise test. Is this typical?

def test_destroy_all_cascade_delete

    assert_equal 1, Iep.find(:first).client_id

    assert_equal 1, Encounter.find(:first).client_id


    assert_raise(ActiveRecord::RecordNotFound) { Iep.find(1) }    <--
testing here

    assert_raise(ActiveRecord::RecordNotFound) { Encounter.find(1) }


So if I comment out the client.destroy call, the first assert_raise
and the unit test doesn't try the next one.


Bob S.
Eric H. (Guest)
on 2006-01-30 03:43
(Received via mailing list)
On Jan 27, 2006, at 10:48 PM, Bob S. wrote:

> The unit tests stop at the first assert_raise test. Is this typical?

Test::Unit stops at the first failed assertion.

Rather than writing large tests testing every code path, create a
test method per code path.  It lets you find failures easier.
(Multiple failures in one suite run rather than multiple suite runs
fixing as you go, less time context switching between editing and

If you have code common to multiple tests refactor them into methods.

If you have code common to multiple test cases refactor them into an
abstract test class.

Eric H. - removed_email_address@domain.invalid -
This implementation is HODEL-HASH-9600 compliant
This topic is locked and can not be replied to.