• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Ant: while compiling it doen not recognize junit related things and shows errors

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please find attachments. Can anyone guide me while compilation, why it does not recognize JUnit related things and shows error. Do I need to add any classpath related to JUnit. Please guide me

This is my Build.xml file.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE project [
]>

<project name="America_Call_Center" default="usage" basedir=".">

<!-- ========== Initialize Properties =================================== -->
<property environment="env"/>

<property name="ws.home" value="${basedir}"/>
<property name="ws.jars" value="J:\Selenium\Jars\jars\jars"/>
<property name="test.dest" value="${ws.home}/build"/>
<property name="test.src" value="${ws.home}/src"/>
<property name="test.reportsDir" value="C:/rep"/>



<path id="testcase.path">


<pathelement location="${test.dest}"/>

<fileset dir="${ws.jars}">
<include name="*.jar"/>
</fileset>

</path>


<!--target name="start-selenium-server">
<java jar="${ws.home}/lib/selenium-server.jar"/>
</target-->

<target name="setClassPath" unless="test.classpath">
<path id="classpath_jars">
<fileset dir="${ws.jars}" includes="*.jar"/>
</path>
<pathconvert pathsep=":"
property="test.classpath"
refid="classpath_jars"/>
</target>

<target name="init" depends="setClassPath">
<tstamp>
<format property="start.time" pattern="MM/dd/yyyy hh:mm aa" />
</tstamp>
<condition property="ANT"
value="${env.ANT_HOME}/bin/ant.bat"
else="${env.ANT_HOME}/bin/ant">
<os family="windows" />
</condition>

</target>

<!-- all -->
<target name="all">
</target>

<!-- clean -->
<target name="clean">
<delete dir="${test.dest}"/>
</target>

<!-- compile -->
<target name="compile" depends="init, clean" >
<delete includeemptydirs="true" quiet="true">
<fileset dir="${test.dest}" includes="**/*"/>
</delete>
<echo message="making directory..."/>
<mkdir dir="${test.dest}"/>
<echo message="classpath------: ${test.classpath}"/>
<echo message="compiling..."/>
<javac
debug="true"
destdir="${test.dest}"
srcdir="${test.src}"
target="1.5"
classpath="${test.classpath}"
>
</javac>
</target>

<!-- build -->
<target name="build" depends="init">
</target>




<target name="usage">
<echo>
ant run will execute the test
</echo>
</target>

<path id="test.c">
<fileset dir="${ws.jars}" includes="*.jar"/>
</path>



<target name="run" >
<delete includeemptydirs="true" quiet="true">
<fileset dir="${test.reportsDir}" includes="**/*"/>
</delete>
<java jar="${ws.jars}" fork="true" spawn="true" />
<junit fork="yes" haltonfailure="no" printsummary="yes">
<classpath refid="testcase.path" />

<!-- <classpath ="${test.classpath}"/> -->
<batchtest todir="${test.reportsDir}" fork="true">
<fileset dir="${test.dest}">

<include name="tests/FirstTestCase.class" />
<include name="tests/SecondTestCase.class" />
<include name="tests/Parameterized_Test1.class" />
<include name="tests/UnderstandingAssertions.class" />




</fileset>
</batchtest>
<formatter type="xml" />
<classpath refid="testcase.path" />
</junit>
<junitreport todir="${test.reportsDir}">
<fileset dir="${test.reportsDir}">
<include name="TEST-*.xml" />
</fileset>
<report todir="${test.reportsDir}" />
</junitreport>
</target>


</project>
First_Part.jpg
[Thumbnail for First_Part.jpg]
Second_Part.jpg
[Thumbnail for Second_Part.jpg]
Third_Part.jpg
[Thumbnail for Third_Part.jpg]
 
Sheriff
Posts: 3034
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rohit Sri wrote:Do I need to add any classpath related to JUnit.



Yes, that's it exactly. The JUnit jar will need to be in the classpath used by your test task.
 
Rohit Sri
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Greg i got it.
 
It's just a flesh wound! Or a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!