ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Hatton" <>
Subject RE: [JUnit] fork mode other than "yes" ignores classpath
Date Fri, 02 Sep 2005 08:14:26 GMT
Hi Marcel,

I don't think you are doing anything wrong, and I don't think it is necessarily a bug either.
Generally <classpath>-type elements are only used when Ant starts a new JVM (<java>,
<javac>, etc.), so this would require your <junit> or <batchtest> element
to have a fork="true" attribute.

However the Ant manual ( page for the Junit task (under
Optional Tasks) doesn't make this clear about the classpath, and some elements (e.g. taskdefs)
can take a classpath without using a separate JVM, so maybe I am wrong, and in either case
perhaps the manual could be clearer about how to ensure that the <classpath> is used
in the <junit> task.


-----Original Message-----
From: Marcel Stör [] 
Sent: 02 September 2005 08:07
Subject: [JUnit] fork mode other than "yes" ignores classpath

Hi all,

In my Ant script (see below) I define my own classpath via a <path> element. Within
the <junit> target I refer to it via <classpath refid="test.classpath" />. However,
JUnit seems to ignore this classpath completely and uses ${java.class.path} only, unless I
use <batchtest fork="yes" .... Am I doing something wrong? Is this a bug?

Marcel Stör

<project name="LoepaTest_B" default="run_junit_tests">

 <!-- This ant task is to run the current Junit-Tests available in the package test -->
 <!-- The output will be generated in report.tests -->

 <property name="rootdir" value="C:/workspaces/eclipse/" />  <property name="src.tests"
value="${rootdir}/LoepaTest_B/" />  <property name="reports.tests" value="C:/temp/Eahv_B/"
/>  <property name="ant.home" value="C:/Programme/ApacheGroup/Ant" />

 <path id="test.classpath">
  <pathelement path="${java.class.path}" />
  <pathelement location="${rootdir}/JaXLionBase/" />
  <pathelement location="${rootdir}LoepaEahv_B/" />
  <pathelement location="${rootdir}LoepaTest_B/" />
  <pathelement location="${rootdir}LoepaWebAppEahv_B/WEB-INF/src/" />

  <fileset dir="${rootdir}/JaXLionCommonRuntimeLibs/" casesensitive="yes">
   <include name="*.jar" />

 <target name="clean">
  <mkdir dir="${reports.tests}" />
   <fileset dir="${reports.tests}">
    <include name="TEST-*.xml" />

 <target name="run_junit_tests" depends="clean">
  <echo message="Information: Die lokal ausgeführten Tests sind nicht die selben wie auf
Anthill." />
  <echo message="Auf der lokalen Workstation werden aus Zeitgründen nicht alle Tests durchgeführt."
  <echo message="Weitere Tests werden auf dem Build Server ausgeführt und befinden sich
im package anthill." />
  <junit haltonerror="false" showoutput="true" errorProperty="test.failed" failureProperty="test.failed">

   <classpath refid="test.classpath" />

   <formatter type="xml" usefile="true" />

   <batchtest fork="yes" todir="${reports.tests}">
    <fileset dir="${src.tests}">
     <include name="test/**/*" />
     <exclude name="**/" />

  <junitreport todir="${reports.tests}">
   <fileset dir="${reports.tests}">
    <include name="TEST-*.xml" />
   <report format="frames" todir="${reports.tests}/html/" />

  <fail if="test.failed">
       Unit tests failed.  Check log or reports for details. ${reports.tests}html/index.html

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message