一件事可能也帮助你这样做:
确保你的配置。常规设置的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'
}
}
在您的测试,这样做:
import org.slf4j.Logger
import org.slf4j.LoggerFactory
class HandoffTests extends GroovyTestCase {
Logger log = LoggerFactory.getLogger(HandoffTests)
... your tests ...
}
如果你这样做,日志会表现的相当多,因为它在该领域一样,服务和控制器对象,其中grails为您自动注入它。我不知道为什么他们没有在测试中自动注入...
您是否知道如何输出junit报告的实际错误?即“预计富,但得到了”。即使使用-testOut和-testErr,它也不会显示,我必须查看target/test-reports/plain/*。txt文件。 – c089 2011-04-13 17:52:23
同样的问题在这里。我必须做这样的事情:$ grails test-app -echoOut -echoErr Something.testMain; cat ./target/test-reports/plain/TEST-integration-integration-SomethingTests.txt有没有人知道一种方法来真正地让它输出一切? Thxx! – jpswain 2011-04-26 21:48:06
感谢您发布这些内容。我只希望我能想出一种方法让控制台输出打印它正在运行的测试名称,而不是“1 xx”。这些-echoOut打印出一些有用的信息,但不是测试名称。 – franzcatch 2017-02-10 21:34:41