> -----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]