ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen McConnell" <>
Subject RE: Broken Junit targets
Date Tue, 14 Feb 2006 05:00:35 GMT

> -----Original Message-----
> From: Taemin Cim [] 
> Sent: Tuesday, 14 February 2006 1:46 PM
> To:
> Subject: RE: Broken Junit targets
> Hi again,
> >The ant-junit.jar is dependent on the JUnit jar file.
> >You can add JUnit to ${ant.home}/lib, or your ${user.home}/.ant/lib 
> >directory.
> >
> >/Steve.
> >
> I have the junit.jar on the test.classpath in the build file. 
>  How else should I associate the junit,jar witht eh 
> ant-junit.jar?   Where should I "add JUnit to ${ant.home}/lib, 
> or your ${user.home}/.ant/lib"  If the junit,jar in on the 
> test classpath, and ant knows it has ant-junit.jar, what more 
> should I do (and how did I break this connection after a year or
> testing?)

There are lots of ways you can play around with classpath composition in
ant.  The important thing to note is that ant-junit requires junit jar to be
in the same or higher classloader.  If the junit jar is present in either
${ant.home}/lib or ${user.home}/.ant/lib then it should be included in the
same classloader that contains ant-junit. This is visible in that when you
compile classes referencing junit classes the compilation succeeds.
However, your forking during the execution of the testcase and (I'm guessing
here) you probably need to provide the complete classloader definition.

>   <target name="test-batch" depends="test-compile">
>     <junit printsummary="withOutAndErr" haltonfailure="false">
>       <classpath refid="test.classpath"/>

Here is an example of the setup of a two path objects that are subsequently
used in a forked junit test.  Perhaps it will help in resolving your issue.

  <target name="setup-path" depends="init">
    <path id="project.main.path">
      <pathelement location="${ENV.ANT_HOME}/lib/ant.jar"/>
      <pathelement location="${target.classes.dir}"/>
    <path id="project.test.path">
      <path refid="project.main.path"/>
      <pathelement location="${ENV.ANT_HOME}/lib/ant-junit.jar"/>

  <target name="test" depends="build-tests" if="src.test.available">
    <junit fork="true" dir="${basedir}"
           haltonfailure="yes" failureproperty="junit.failure"
           haltonerror="yes" errorproperty="junit.error">
        <path refid="project.test.path"/>
        <pathelement location="${target.test-classes.dir}"/>
      <formatter type="plain"/>
      <formatter type="xml"/>
      <batchtest fork="yes" todir="${target.test-reports.dir}">
        <fileset dir="${}">
          <include name="**/*"/>
          <exclude name="**/Abstract*.java"/>

Cheers, Steve.

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

View raw message