Test unit - result output written to database?

Hi everyone,

I have some code I inherited which is using Test Unit on Ruby 1.8.7.

I would like to have the results of the test run written to a database,
instead of just displayed on the screen.

Something along the lines of each test result becoming a record in a
database and would contain data like the test id, the test result
(pass/fail), and the reason for failure.

For the successful test cases, I think this is rather simple to do.

But for the assertions that fail, the code for the test case ceases
execution at the point of the failed assertion.

Currently I am writing a wrapper for the assertion, that
will test the condition, write the record to the database if the
condition failed, then do the actual assertion.

Is there a better way to execute a block of code when an assertion
fails?

Thanks in advance!