用于即时转储控制台输出的 ant junit 任务选项 [英] option for ant junit task to dump console output on-the-fly

查看:25
本文介绍了用于即时转储控制台输出的 ant junit 任务选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Ant junit 任务启动非回归测试时遇到问题:控制台输出仅在测试结束时转储.当与进程 Xmx 相关的日志过多时,它会导致一些 OOM,这意味着如果进程在结束前死亡(或被看门狗杀死),日志将丢失.

I have an issue when using the Ant junit task to launch my non-regression tests: the console output is only dumped when the test end. It causes some OOM when there are too many logs with respect to the process Xmx and means that if the process dies (or is killed by a watchdog) before its end the logs are lost.

<junit fork="true" forkmode="once" timeout="1200000" haltonfailure="no" 
 outputtoformatters="yes" failureProperty="test.failure" dir="${project.test.dir}">
  <junit-opts/>
  <formatter type="xml" />
  <formatter type="brief" />
  <test name="${project.test.suite}" todir="${report.junit.dir}" outfile="@{project.test.name}" />
</junit>

当然可以通过将日志转储到文件中来解决这个问题(我们使用 log4j 作为日志记录 API).但是,我们非常想测试应用程序的控制台输出日志.

The issue could be worked around by dumping the logs in a file (we use log4j as a logging API), certainly. However we would very much like to test the console output logs of the application.

是否有允许告诉 ant junit 任务即时将控制台输出转储到文件中而不是等待测试套件结束的设置?

Is there a setting permitting to tell the ant junit task to dump the console output in a file on-the-fly and not to wait for the test suite to end?

谢谢!

推荐答案

添加 showoutput="true" 参数,到 junit 命令:

Add showoutput="true" parameter, to junit command:

<junit fork="true" showoutput="true" forkmode="once" timeout="1200000" haltonfailure="no" 
 outputtoformatters="yes" failureProperty="test.failure" dir="${project.test.dir}">
  <junit-opts/>
  <test name="${project.test.suite}" todir="${report.junit.dir}" outfile="@{project.test.name}" />
</junit>

避免使用 showoutput="true" 和格式化程序.这是有问题的,因为这意味着 test stdout &stderr 在输出窗口中出现两次(在运行时,因为 showoutput 标志,在执行后,因为格式化程序).

Avoid using showoutput="true" and formatters. It is problematic, because it means that test stdout & stderr appears twice in the Output Window (in runtime, because showoutput flag, and after execution, because formatters).

这篇关于用于即时转储控制台输出的 ant junit 任务选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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