ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raymond K. DeCampo" <rkdeca...@promergent.com>
Subject JUnit, ANT, log4j, System.out issue
Date Mon, 21 Mar 2005 14:22:38 GMT
Hello,

I am experiencing an issue with the combination of ANT, JUnit and
log4j. Here's the situation. The ANT build file uses the <junit>
task. Log4j is configured to print to the console. There are also
times when the unit tests use System.out directly. The problem is
that the log4j statements are not captured by the <junit> as part of
the standard output. The logging statements do appear on the console
when I run the tests. But since they are not captured by <junit>,
they do not appear in the XML files and are lost forever.

I originally posted this message to the JUnit list.  Since then I have 
discovered that if I do not fork the JUnit process everything behaves
as I expect.  Not forking the JUnit process is not really an option,
as there are quite a few unit tests and I run into memory issues.

Here's the ANT target:

<target name="run-test" depends="init,test-setup">
<!-- execute the test -->
<junit fork="yes"
       dir="${basedir}"
       haltonfailure="${test.halt.on.failure}"
       printsummary="withOutAndErr">
    <classpath refid="test.classpath" />
    <formatter type="xml" />
    <formatter type="plain" usefile="false"/>
    <jvmarg line="${test.jvmargs}" />
    <batchtest fork="yes" todir="${test.report.xml.dir}">
        <fileset dir="${test.src}" >
            <include name="${test.full.includes}" />
            <exclude name="${test.full.excludes}" />
        </fileset>
    </batchtest>
</junit>
</target>

Here's the log4j configuration:

<log4j:configuration debug="false">
<appender name="SYS_OUT" class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out"/>
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%-5p %c{2} -%m%n"/>
    </layout>
</appender>

<root>
    <level value="INFO"/>
    <appender-ref ref="SYS_OUT"/>
</root>
</log4j:configuration>

Version information:
[09:19 C:/] ant -version
Apache Ant version 1.6.0 compiled on December 18 2003
log4j 1.2.8
JUnit 3.8.1

If anybody could enlighten me on the subject, I'd appreciate it.

Thanks, 

Raymond DeCampo
Software Architect
PROMERGENT 
5010 Campuswood Drive - East Syracuse NY 13057
315.414.9855 x411 || 315-414-9856 f
http://www.promergent.com

PEOPLE . PROCESS . DATATM
This electronic transmission contains information from Progressive Software Solutions, Inc.
(d/b/a ProSoft, d/b/a PROMERGENT), which may be company confidential and/or company private.
The information contained herein is intended for the exclusive use of the addressee named
above. If you are not the intended recipient, be aware that any disclosure, copying, distribution
or use of this information is prohibited. If you have received this electronic mail transmission
in error, please notify us by telephone or by electronic mail.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message