One thing that might also help you is doing this:
Make sure your Config.groovy sets up log4j:
import grails.util.GrailsUtil
if (GrailsUtil.environment == 'test') {
log4j = {
appenders {
// %d{yyyyMMdd.HHmmss.SSS} %r [%t] %-5p %c %x - %m%n
console name:'a1', layout:pattern(conversionPattern: '%d{yyyyMMdd.HHmmss.SSS} %r [%t] %-5p %c %x - %m%n')
}
root {
info 'a1'
additivity = true
}
// debug 'org.springframework.security'
error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate',
'org.apache',
'grails.util.GrailsUtil',
'grails.app.service.NavigationService',
'org.quartz',
'net.sf.ehcache'
fatal 'NotificationJob'
warn 'org.mortbay.log',
'groovyx.net.ws', // Web services too noisy with INFO statements
'org.apache.cxf.endpoint.dynamic' // Web services too noisy with INFO statements
info 'org.springframework.security'
debug 'grails.app.controller.TroublesomeController'
}
}
In your test, do this:
import org.slf4j.Logger
import org.slf4j.LoggerFactory
class HandoffTests extends GroovyTestCase {
Logger log = LoggerFactory.getLogger(HandoffTests)
... your tests ...
}
If you do this, log will behave the pretty much the same as it does in the domain, service, and controller objects, where grails auto-injects it for you. I have no idea why they don't auto-inject in tests...