# Test::Unit and logging

**URL:** <https://www.ruby-forum.com/t/test-unit-and-logging/99700>\
**Category:** Ruby\
**Created:** [July 25, 2006, 12:56am UTC](https://www.ruby-forum.com/t/test-unit-and-logging/99700 "2006-07-25T00:56:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lstrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@lstrecv](https://www.ruby-forum.com/u/lstrecv)\
**Post date:** [July 25, 2006, 12:56am UTC](https://www.ruby-forum.com/t/test-unit-and-logging/99700/1 "2006-07-25T00:56:44Z")

</div>

Is there a simple way to have Test::Unit use Log4r (or Logger) to add a  
log message whenever a test fails?

My first step in debugging is to look at the logs. But, with copious  
logs, it’s hard to find the case which failed. It would be great if I  
could just search the log for the message of the test failing.

---

<div class="post-metadata">

**Author:** ![lstrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@lstrecv](https://www.ruby-forum.com/u/lstrecv)\
**Post date:** [July 25, 2006, 2:42pm UTC](https://www.ruby-forum.com/t/test-unit-and-logging/99700/2 "2006-07-25T14:42:58Z")

</div>

On Jul 24, 2006, at 6:55 PM, removed\_email\_address@domain.invalid wrote:

> Is there a simple way to have Test::Unit use Log4r (or Logger) to  
> add a  
> log message whenever a test fails?
> 
> My first step in debugging is to look at the logs. But, with copious  
> logs, it’s hard to find the case which failed. It would be great if I  
> could just search the log for the message of the test failing.

I’m no expert here, but since your question still doesn’t have a  
reply…

Have you looked into the various continuous integration solutions.  
You’ll need some googling, but they’re designed to run tests  
regularly against a repository and do things like send emails when a  
test fails. They may be configurable to log as well.

Finally, I’d dig into the code for Test::Unit::TestCase to find how  
it displays failures. There might be a function you can over-ride or  
replace easily enough to create the log messages you’re looking for.  
-Mat
