Hi,
I'm still getting the same "Could not create task or type of type: junit"
error.
I created a separate ant-junit pathelement in the properties.xml file:
<property name="junit.jar"
location="${junit.dir}/junit.jar"/>
<property name="ant-junit.jar"
location="${ant.home}/lib/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"/>
</path>
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>
<path id="project.test.path">
<path refid="project.main.path"/>
<pathelement location="${ant-junit.jar}"/>
<pathelement location="${junit.jar}"/>
</path>
</target>
<!-- refid changed from test.classpath to setup-path -->
<target name="test" depends="test-compile">
<junit printsummary="true"
errorProperty="test.failed"
failureProperty="test.failed"
fork="${junit.fork}">
<classpath>
<path refid="setup-path"/>
<pathelement path="${java.class.path}"/>
</classpath>
<formatter type="brief" usefile="true"/>
<formatter type="xml"/>
<test name="${testcase}" todir="${test.data.dir}" if="testcase"/>
<batchtest todir="${test.data.dir}" unless="testcase">
<fileset dir="${test.dir}" includes="**/*Test.class"/>
</batchtest>
</junit>
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" <[EMAIL PROTECTED]>
Reply-To: "Ant Users List" <user@ant.apache.org>
To: "'Ant Users List'" <user@ant.apache.org>
Subject: RE: Broken Junit targets
Date: Tue, 14 Feb 2006 15:30:35 +1030
> -----Original Message-----
> From: Taemin Cim [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, 14 February 2006 1:46 PM
> To: user@ant.apache.org
> 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>
<path id="project.test.path">
<path refid="project.main.path"/>
<pathelement location="${ENV.ANT_HOME}/lib/ant-junit.jar"/>
<pathelement
location="${dpml.local.cache}/junit/jars/${junit.filename}"/>
</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="${target.build.test.dir}">
<include name="**/*TestCase.java"/>
<exclude name="**/Abstract*.java"/>
</fileset>
</batchtest>
</junit>
</target>
Cheers, Steve.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]