wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes How to run JUNIT Tester with Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How to run JUNIT Tester with Ant " Watch "How to run JUNIT Tester with Ant " New topic
Author

How to run JUNIT Tester with Ant

Micky Morgan
Greenhorn

Joined: Sep 20, 2006
Posts: 19
I am newbie to Ant. I have read the previous posts about JUNIT/ANT. But I am not quite sure how to resolve my issues...

I can run the JUNIT Tester using the below batch file...

---------------Tester.bat------------
set CLASSPATH="C:\a.jar";"C:\b.jar";"C:\junit-4.1.jar"
C:\jdk1.5.0_06\bin\java -classpath %CLASSPATH% org.junit.runner.JUnitCore com.thoughtworks.selenium.QATester
---------------------------------

If I run the above, batch file, QATester class executes since QATester.class is part of b.jar file.

Now, I have 2 issues...

1) How can I convert the above batch file into Ant target
2) QATester.class file launches http://hostname:8080/xyz . I have hard coded hostname in the class file. Now, my question, how can I pass this hostname as an argument from the Ant target?

Please response. I have been struggling a lot to resolve...

Thanks in advance
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Micky Morgan:
Please response. I have been struggling a lot to resolve...


What have you tried so far?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Micky Morgan
Greenhorn

Joined: Sep 20, 2006
Posts: 19
I tried to run the Class file as below:

<target name="init">
<tstamp/>
<property name="Base" value="C:\"/>
<path id="ccp" description="The CLASSPATH for compiling and running">
<pathelement location="${Base}\a.jar" />
<pathelement location="${Base}\b.jar" />
<pathelement location="${Base}\JUnit.4.1.jar" />
<pathelement location="." />
</path>
</target>

<target name="run" depends="init">
<java classname="com.thoughtworks.selenium.QATester"
fork="true"/>
<classpath refid="ccp" />
</target>
Micky Morgan
Greenhorn

Joined: Sep 20, 2006
Posts: 19
I am answering my own question. I got it from Ant Manual.

<target name="run" depends="on_prev_task">
<java classname="org.junit.runner.JUnitCore">
<arg value="com.thoughtworks.selenium.QATester"/>
<classpath>
<pathelement location="C:\Selenium-RC\java\junit-4.1.jar"/>
<pathelement location="C:\Selenium-RC\java\b.jar"/>
<pathelement path="${java.class.path}"/>
</classpath>
</java>
</target>
 
wood burning stoves
 
subject: How to run JUNIT Tester with Ant