是否可以在jUnit测试运行期间禁用log4j异常输出? [英] Is it possible to disable log4j exception output during jUnit tests run?

查看:281
本文介绍了是否可以在jUnit测试运行期间禁用log4j异常输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jUnit测试运行期间需要禁用log4j输出到控制台,但所有其他log4j输出都应启用.在测试过程中检查不正确的参数的方法响应时会有很多异常,因此可以使用异常.

Need to disable log4j output to console during jUnit tests running but all other log4j output should be enable. There are lot exceptions during testing while checking method reaction on incorrect argument, so exception is ok.

推荐答案

创建一个名为例如的新log4j属性文件. log4j-test.properties,禁用日志记录.在POM的surefire配置中,添加argLine-Dlog4j.configuration=log4j-test.properties.

Create a new log4j properties file called e.g. log4j-test.properties with logging disabled. In your surefire config in the POM, add argLine with -Dlog4j.configuration=log4j-test.properties.

这篇关于是否可以在jUnit测试运行期间禁用log4j异常输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆