gpt4 book ai didi

JUnit5 属性文件在测试运行期间导致不需要的日志记录

转载 作者:行者123 更新时间:2023-12-02 11:21:13 29 4
gpt4 key购买 nike

我已将默认测试生命周期设置为 per_class对于使用 JUnit5 的项目。这是在 junit-platform.properties 中完成的文件。但是,自从应用此配置后,我的测试运行之前会出现大量日志记录输出:

Dec 06, 2018 8:15:22 PM org.junit.platform.launcher.core.LauncherConfigurationParameters fromClasspathResource
INFO: Loading JUnit Platform configuration parameters from classpath resource [file:/Users/amb85/Projects/kotlin/katas/out/test/resources/junit-platform.properties].
Dec 06, 2018 8:15:22 PM org.junit.jupiter.engine.descriptor.TestInstanceLifecycleUtils getDefaultTestInstanceLifecycle
INFO: Using default test instance lifecycle mode 'PER_CLASS' set via the 'junit.jupiter.testinstance.lifecycle.default' configuration parameter.

我不想看到这些日志消息。如何禁用它们或将日志级别设置得更高?

最佳答案

在以下位置找到了答案:
https://github.com/junit-team/junit5/issues/1774#issuecomment-463662553
总结:
将“java.util.logging.config.file”系统属性设置为指向降低日志级别的 logging.properties 文件。

 tasks.withType(Test).configureEach {
useJUnitPlatform()

systemProperty 'java.util.logging.config.file', "${project.buildDir}/resources/test/logging-test.properties"

testLogging {
showStandardStreams = true
}
}
日志-test.properties:
handlers=java.util.logging.ConsoleHandler
.level=INFO

org.junit.platform.launcher.core.LauncherConfigurationParameters.level=WARNING
org.junit.jupiter.engine.config.EnumConfigurationParameterConverter.level=WARNING

关于JUnit5 属性文件在测试运行期间导致不需要的日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53659052/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com