views:

35

answers:

2

How do I setup logging in a grails unit-test?

When I try log.info or log.debug, the .txt output files are empty, even after I tried adding a console appender. What's going on here?

A: 

If you extend GrailsUnitTestCase, you ought to be able to use mockLogging(), but the appenders you set up in Grails config won't be applied in a unit test, which works in isolation from the real framework. They'd only be available in integration tests.

John Stoneham
These are integration tests.
Stefan Kendall
mockLogging does not work.
Stefan Kendall
+1  A: 

This might help, it's taken from the 1.2 release notes

By default, grails does not show the output from your tests. You can make it do so by passing -echoOut and/or -echoErr to test-app:

grails test-app -echoOut -echoErr

Don