Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

option for ant junit task to dump console output on-the-fly

Tags:

junit

log4j

ant

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>

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.

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?

Thanks!

like image 899
Guillaume Avatar asked Jan 31 '13 08:01

Guillaume


1 Answers

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>

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).

like image 200
voji Avatar answered Sep 22 '22 02:09

voji