LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 02-18-2005, 09:29 PM   #1
Hockeyfan
Member
 
Registered: May 2004
Distribution: SuSe 10.0
Posts: 154

Rep: Reputation: 30
Question about Apache Ant


I am about to start developing applications using Ant. I have decided to try programming using JUnit (Test-Driven Development). I created the build.xml file that I found on Apache Ant's Documentation page. The only problem that I have is that I do not have a jar package named ant-testutil.jar. I did a goggle search and found a page that told me that in order to create the jar file i needed the source files. I have searched my installation cd's and I can not find the developmental package for Ant. I downloaded the src file from Apache's website. I haven't installed it yet thinking that there will be a conflict with the already installed Ant.

So my question is has anyone used Ant with JUnit and used ant-testutil.jar? Do I need ant-testutil or is there a different jar file I could use?

Running SuSe 9.2 pro
Ant 1.6.2
JUnit 3.8.1-3 ( According to YaST; can't seem to run from command prompt but installed on my system. I think it was installed with eclipse)

Hockeyfan
 
Old 02-19-2005, 07:57 AM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
Can you show us the sections of your build file?

Here is an example of a build file I created that does junit testing.

Code:
<project name="antlab-resources" default="all" basedir=".">
    <description>
        Build.xml file for Antlab-resources Project
    </description>
    <property name="src" location="."/>

    <path id="classpath">
        <pathelement path="${classpath}"/>
        <pathelement path="."/>
        <pathelement location="/net/hu15/cs2335/java/junit/junit.jar"/>
    </path>

    <target name="compile" description="compile java source" >
        <javac srcdir="." destdir=".">
            <classpath refid="classpath"/>
        </javac>
    </target>

    <target name="test" depends="compile" description="run tests" >
        <junit printsummary="yes" haltonfailure="yes" haltonerror="yes">
            <classpath>
                <pathelement location="${build.tests}"/>
                <pathelement path="${src}"/>
            </classpath>

            <formatter type="plain"/>


          <batchtest fork="yes" todir="${src}">
              <fileset dir="${src}">
                  <include name="**/*Test*.java"/>
              </fileset>
          </batchtest>
    </junit>
    </target>

    <target name="all" depends="compile,test" description="build,
    jar, javadoc, and run" />

</project>
 
Old 02-19-2005, 02:17 PM   #3
Hockeyfan
Member
 
Registered: May 2004
Distribution: SuSe 10.0
Posts: 154

Original Poster
Rep: Reputation: 30
Here is my builld.xml file
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Blackjack" basedir="." default="test">

	<property name="src.dir" value="src" />
	<property name="classes.dir" value="classes" />
	<property name="report.dir" value="report"/>
	<property name="ant.test.lib" value="ant-testutil.jar"/>
	<property name="junit.out.dir.xml" value="${report.dir}/junit/xml"/>
	<property name="junit.out.dir.html" value="${report.dir}/junit/html"/>

	<path id="classpath.run">
		<path path="${java.class.path"/>
		<path location="${ant.project.name}.jar"/>
	</path>
	<path id="classpath.test">
		<path refid="classpath.run"/>
		<path location="${ant.test.lib}"/>
	</path>

	<target name="clean" description="Delete all generated files">
		<delete  failonerror="false" includeEmptyDirs="true"/>
			<fileset dir="." includes="${ant.project.name}".jar />
			<fileset dir="${classes.dir}" />
			<fileset dir="${report.dir}" />
		</delete>
	</target>

	<target name="compile" description="Compiling all source files">
		<mkdir dir="${classes.dir}"/>
		<javac srcdir="${src.dir}" destdir="${classes.dir" classpath="${ant.test.lib}" />
	</target>

	<target name="jar" desription="Jar all files" dependson="compile">
		<jar destfile="${ant.project.name}.jar" basedir="${classes.dir}"/>
	</target>

	<target name="use" description="Use the project" depends="jar">
		<taskdef name="blackjack" classname="Blackjack" classpath="${ant.project.name}.jar"/>
		<blackjack/>
	</target>
	<target name="junit" description="Running Unit tests" depends="jar">
		<delete dir="${junit.out.dir.xml}" />
		<mkdir dir="${junit.out.dir.xml}" />
		<junit printsummary="yes" haltonfailure="no">
			<classpath refid="classpath.test"/>
			<formatter type="xml"/>
			<batchtest fork="yes" todir="${junit.out.dir.xml}">
				<fileset dir="${src.dir}" includes="**/*Test.java"/>
			</batchtest>
		</junit>
	</target>
	<target name="junitreport" desription="Creates a report for the rest result">
		<mkdir dir="${junit.out.dir.html}" />
		<junitreport todiir="${junit.out.dir.html}">
			<fileset dir="${junit.out.dir.xml}">
				<include name="*.xml"/>
			</fileset>
			<report format="frames" todir="${junit.out.dir.html}" />
		</junitreport>
	</target>
	<target name="test"
			depends="junit, junitreport"
			descriiption="Run unit tests and creates a report"
	/>
	</target>
</project>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems about ant simprince Programming 1 11-08-2005 10:53 AM
Apache Ant and Red Hat Enterprise WS 4 AsymptoticOrbit Red Hat 4 08-22-2005 09:02 PM
problem with ant os2 Programming 1 05-20-2005 01:13 AM
creating apache-ant package merchtemeagle Slackware 3 05-11-2005 02:12 PM
Jakarta Ant?? powadha Linux - Software 3 01-19-2004 01:46 PM


All times are GMT -5. The time now is 10:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration