Ant/JUnit question


T

Tim

I've got Ant/JUnit working so that it compiles, creates an executable
jar file and runs a JUnit test class.
My question is...how does it know where to find the test class? I don't
seem to be specifying it anywhere that I can see.



<?xml version="1.0"?>
<project name="test" default="compile"
basedir="C:/JDeveloper/jdev/mywork/WorkspaceBeans/Project3">
<property name="src" value="src"/>
<property name="build" value="classes"/>
<property name="dist" value="dist"/>
<path id="classpath">
<fileset dir="C:/JDeveloper">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="compile"
description="compile the source " >
<javac srcdir="${src}" destdir="${build}" >
<include name="*.java" />
<classpath refid="classpath"/>
</javac>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >

<!-- Put everything in ${build} into the MyProject.jar file -->
<jar jarfile="${dist}/MyProjectX.jar" basedir="${build}">
<manifest>
<attribute name="Main-Class"
value="junitTest.HelloWorldTest"/>
<attribute name="Class-Path" value="junit.jar"/>
</manifest>
</jar>
</target>
<!-- This one runs junitTest.HelloWorldTest non-graphically -->
<target name="junit" depends="dist">
<property name="testclass" value="junitTest.HelloWorldTest"/>
<java classname="junit.textui.TestRunner">
<arg value="${testclass}"/>
<classpath>
<fileset dir="C:/JDeveloper"
includes="**/*.jar"/>
</classpath>
</java>
</target>
</project>
 
Ad

Advertisements

J

Jose Rubio

It gets it from the jar file that is included in the classpath of the junit
execution. The class to test is specified in the testclass property.

You might want to check out the <junit> tag in Ant. It allows you to do
batch tests and create reports. Check the ant documentation.

Jose
 
T

Tim

So does that "**/*.jar" mean to look in all the files that end in .jar
in ALL of the directories below C:/JDeveloper?
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top