Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to run JUNIT Tester with Ant

 
Micky Morgan
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Micky Morgan:
Please response. I have been struggling a lot to resolve...


What have you tried so far?
 
Micky Morgan
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic