ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Taemin Cim" <>
Subject RE: Broken Junit targets
Date Wed, 15 Feb 2006 03:01:41 GMT

I'm still getting the same "Could not create task or type of type: junit" 
I created a separate ant-junit pathelement in the properties.xml file:

    <property name="junit.jar"

  <property name="ant-junit.jar"

I then reference both in the build.xml file:

  <path id="test.classpath">
    <path refid="compile.classpath"/>
    <pathelement location="${junit.jar}"/>
    <pathelement location="${ant-junit.jar}"/>
    <pathelement location="${build.dir}/classes"/>
    <pathelement location="${build.dir}/test"/>

Same error.

I changed the <property name="junit.fork" value="true"/> to value="false"

Same error.

So I tried to implement the setup-path and test targets as Steve suggested:

  <!-- Suggested by Stephen McConnell -->
  <target name="setup-path" depends="init">
    <path id="project.main.path">
      <pathelement location="${ant.jar}"/>
      <pathelement location="${build.dir}/classes"/>
    <path id="project.test.path">
      <path refid="project.main.path"/>
      <pathelement location="${ant-junit.jar}"/>
      <pathelement location="${junit.jar}"/>

  <!--  refid changed from test.classpath to setup-path -->
  <target name="test" depends="test-compile">
    <junit printsummary="true"
        <path refid="setup-path"/>
        <pathelement path="${java.class.path}"/>
      <formatter type="brief" usefile="true"/>
      <formatter type="xml"/>
      <test name="${testcase}" todir="${}" if="testcase"/>
      <batchtest todir="${}" unless="testcase">
        <fileset dir="${test.dir}" includes="**/*Test.class"/>

Same error.

I still don't understand how, without changing any environment path settings 
or anything elese, copying the junit.jar to a side projects lib directory 
has broken the test target for all other projects on my system.
There must be some kind of classloader memory that survives reboots that I 
offended with the seemingly innocuos copy file which I was then unable to 
erase by deleting the offending jar.

>From: "Stephen McConnell" <>
>Reply-To: "Ant Users List" <>
>To: "'Ant Users List'" <>
>Subject: RE: Broken Junit targets
>Date: Tue, 14 Feb 2006 15:30:35 +1030
> > -----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 
>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 
>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>
>     <path id="project.test.path">
>       <path refid="project.main.path"/>
>       <pathelement location="${ENV.ANT_HOME}/lib/ant-junit.jar"/>
>       <pathelement
>     </path>
>   </target>
>   <target name="test" depends="build-tests" if="src.test.available">
>     <junit fork="true" dir="${basedir}"
>            printsummary="yes"
>            showoutput="true"
>            haltonfailure="yes" failureproperty="junit.failure"
>            haltonerror="yes" errorproperty="junit.error">
>       <classpath>
>         <path refid="project.test.path"/>
>         <pathelement location="${target.test-classes.dir}"/>
>       </classpath>
>       <formatter type="plain"/>
>       <formatter type="xml"/>
>       <batchtest fork="yes" todir="${target.test-reports.dir}">
>         <fileset dir="${}">
>           <include name="**/*"/>
>           <exclude name="**/Abstract*.java"/>
>         </fileset>
>       </batchtest>
>     </junit>
>   </target>
>Cheers, Steve.
>To unsubscribe, e-mail:
>For additional commands, e-mail:

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

View raw message