在单元测试中输出Gradle java.util.logging.Logger输出 [英] Gradle java.util.logging.Logger output in unit tests
问题描述
抱歉,这可能是一个非常简单的问题。
我正在使用 gradle 为我的开发环境。它很好用!
我写了一个使用 HtmlUnit
和我自己的包的简单单元测试。
对于我自己的包,我使用 java.util.Logger
。
HtmlUnit
似乎使用公共日志记录。
我希望看到来自 java.util.Logger的日志消息的控制台输出
然而,即使信息级别的消息在我的单元测试结果GUI(System.err链接)中也不显示,尽管 HtmlUnit
如果您有任何建议,请让我知道。
谢谢!
Misha
好的。我想到了。这很奇怪。
即,如果我在任何方法的外部初始化记录器:
class foo {
def log = Logger.getLogger(this.class.name)
}
当我编写测试时,没有看到日志输出。
然而,如果我初始化记录器里面构造函数 class foo {
def log
foo() {
log = Logger.getLogger(this.class.name)
}
}
然后它工作正常。奇怪...
谢谢!
Misha
Sorry, this is probably a very simple question.
I am using gradle for my development environment. It works quite well!
I have written a simple unit test that uses HtmlUnit
and my own package.
For my own package, I use java.util.Logger
.
HtmlUnit
seems to use commons logging.
I would like to see console output of my logging messages from java.util.Logger
However, it seems that even messages at the info level are not displayed in my Unit Test Results GUI (System.err link), although the HtmlUnit
messages are all displayed.
Please let me know if you have suggestions.
Thank you! Misha
Ok. I figured it out. It was quite odd.
Namely, if I initialize the logger outside of any methods:
class foo {
def log=Logger.getLogger(this.class.name)
}
log output is not seen when I write a test.
However, if I initialize the logger inside the constructor
class foo {
def log
foo() {
log=Logger.getLogger(this.class.name)
}
}
Then it works fine. Odd...
Thank you! Misha
这篇关于在单元测试中输出Gradle java.util.logging.Logger输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!