ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Hatton" <khat...@axiomsystems.com>
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 (http://ant.apache.org/manual/index.html) 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.

Keith


-----Original Message-----
From: Marcel Stör [mailto:marcel@frightanic.com] 
Sent: 02 September 2005 08:07
To: user@ant.apache.org
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
http://www.frightanic.com



<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" />
  </fileset>
 </path>

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


 <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/**/*Test.java" />
     <exclude name="**/AllTests.java" />
    </fileset>
   </batchtest>
  </junit>

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

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


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


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


Mime
View raw message