• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JUnit not found...

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I typed 'ant' and I get this error:
JUnit not found in Ant's CLASSPATH!
How do I set the CLASSPATH? I prefer using DOS in these issues.
Thank you.
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put junit.jar in your %ANT_HOME%/lib directory
 
Rami Sawas
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's already there...
To make sure, how would I set the CLASSPATH in DOS command.
Thanks again.
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rami Sawas:
It's already there...
To make sure, how would I set the CLASSPATH in DOS command.
Thanks again.


You don't set the CLASSPATH. When you run 'ant' (which is a bat file), it sets and uses its own classpath, built from the jars it finds in the lib directory. So my guess is you are running some other 'ant' script, not the one that comes with ant.
 
Rami Sawas
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well basically, I downloaded a shopping cart from the Internet and trying to make it work after downloading the necessary software.
The build.xml in the Framework\Lab directory (shoppinf cart)uses an external entity to basically import buildCommon.xml that is in the top directory. That file defines where many libraries like Xerces and Xalan should be found. I unzipped Xerces and Xalan to different directories then I either have to move them or modify buildCommon.xml to point to them.
I modified alot of buildCommom.xml to match my files. But there are few sections which I left them as they are maybe you could help me out.
The code below is quiet big. I couldn't reduce it less than that because I thought I would give you a clear picture of what buildCommon.xml includes. I've removed bits which I think are not related to Ant-Junit.
There are bits which are bold either need to be changed but don't know how or don't what they represent(in other words are they important to be there).
Thank you.

<property name="junitRoot" value="C:"/>
<property name="antDir" value="${antRoot}/apache-ant-1.6.0"/>
<property name="junitDir" value="${junitRoot}/apache-ant-1.6.0"/>
<property name="ant" value="${antDir}/lib/ant.jar"/>
<property name="buildDir" value="classes"/>
<property name="docDir" value="doc"/>
<property name="docRoot" value="docroot"/>
<property name="javadocDir" value="${docDir}/api"/>
<property name="junit" value="${junitDir}/lib/ant-junit.jar"/>
<property name="libDir" value="lib"/>[/B]
<property name="srcDir" value="src"/>[/B]
<property name="util" value="Util/classes"/>

<target name="cleanTestLogs" description="deletes generated JUnit log files">
<delete>
<fileset dir=".">
<include name="TEST-*.txt"/> <!-- generated by the test target -->
</fileset>
</delete>
</target>

<target name="compile" depends="prepare" description="compiles source files">
<javac srcdir="${srcDir}" destdir="${buildDir}"
classpathref="classpath" deprecation="on"/>
</target>

<target name="compileUtil" unless="utilCompiled"
description="compiles Util source files">
<ant dir="../../Util" target="compile"/>
</target>

<target name="init" description="performs initialization steps">
<parallel>
<available property="haveJUnit"
classpath="${junit}" classname="junit.framework.TestCase"/>
</parallel>
</target>
<target name="javadoc" depends="compile"
description="generates javadoc from all .java files">
<delete dir="${javadocDir}"/>
<mkdir dir="${javadocDir}"/>
<javadoc sourcepath="${srcDir}" destdir="${javadocDir}"
packagenames="com.*" classpathref="classpath"/>
</target>

<target name="prepare"
depends="init,verifyant-junit,verifyMySQL,verifyTomcat,verifyXalan,verifyXerces"
description="create output directories">
<parallel>
<mkdir dir="${buildDir}"/>
<mkdir dir="${docDir}"/>
<mkdir dir="${libDir}"/>
<available property="utilCompiled" file="Util/classes"/>
</parallel>
</target>

<target name="run" depends="compile" description="runs main class">
<java classname="${mainClass}" classpathref="classpath" fork="yes"/>
</target>

<target name="test" depends="compile,cleanTestLogs"
description="runs all ant-junit tests">
<ant-junit fork="yes" printsummary="yes">
<classpath refid="classpath"/>
<batchtest>
<fileset dir="${srcDir}">
<include name="**/*Test.java"/>
</fileset>
<formatter type="plain"/>
</batchtest>
</ant-junit>
</target>
<target name="verifyant-junit" unless="haveant-junit">
<fail message="ANT-JUnit not found in Ant's CLASSPATH!"/>
</target>

<target name="zip" description="zips files in this directory">
<zip zipfile="${zipFile}" basedir="."
excludes="${zipFile},${buildDir}/**,${javadocDir}/**"/>
</target>
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<target name="verifyant-junit" unless="haveant-junit">

Where do you set your haveant-junit property?
[ February 07, 2004: Message edited by: Marilyn de Queiroz ]
 
Rami Sawas
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whenever you see ant-junit, it's the same as junit. The reason for having 2 names is that I changed the name 'junit' to 'ant-junit' to match the name of the file in my ANT directory.
Is it a problem if I change the name of the file to match the code?
Anyway, I'm keeping it as 'jnuit'.
<target name="init" description="performs initialization steps">
<parallel>
<available property="haveJUnit"
classpath="${junit}" classname="junit.framework.TestCase"/>

<available property="haveMySQL" file="${mysqlDir}" type="dir"/>
<available property="haveTomcat" file="${tomcatDir}" type="dir"/>
<available property="haveXalan" file="${xalan}" type="file"/>
<available property="haveXerces" file="${xercesImpl}" type="file"/>
</parallel>
</target>

By the way, when I type in 'ant -v', it gave me this...
'Unable to load class junit.framework.TestCase'
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems to me that if you set a property named haveJUnit that you would need to test for a property named haveJUnit and not for a property named haveant-junit.

I would suggest that you try changing one of them so they are identical, whichever one you prefer -- haveant-junit or haveJUnit.
 
Rami Sawas
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've changed everything to 'junit' but still face the same problem. "Junit" was already in the ANT folder under the name "Ant-Junit" so I just changed it to "Junit" ..hope it doesn't cause much of a problem.
I'm actually worried about these 3 pieces of code. I copy/paste exactly from builCommon.xml
<target name="compile" depends="prepare" description="compiles source files">
<javac srcdir="${srcDir}" destdir="${buildDir}"
classpathref="classpath" deprecation="on"/>
</target>
<target name="compileUtil" unless="utilCompiled"
description="compiles Util source files">
<ant dir="../../Util" target="compile"/>
</target>
<target name="init" description="performs initialization steps">
<parallel>
<available property="haveJUnit"
classpath="${junit}" classname="junit.framework.TestCase"/>
</parallel>
</target>
Don't I have to put some kind of an actually value or directory instead of "classpath"?
Don't I have to put some real directory instead of ".../../Util"
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic