wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant: while compiling it doen not recognize junit related things and shows errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant: while compiling it doen not recognize junit related things and shows errors" Watch "Ant: while compiling it doen not recognize junit related things and shows errors" New topic
Author

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

Rohit Sri
Greenhorn

Joined: Mar 01, 2013
Posts: 3
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>


[Thumbnail for First_Part.jpg]

[Thumbnail for Second_Part.jpg]

[Thumbnail for Third_Part.jpg]

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

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

Joined: Mar 01, 2013
Posts: 3
Thanks Greg i got it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ant: while compiling it doen not recognize junit related things and shows errors
 
Similar Threads
Reference junit.path not found while running ANT
ANT problem running unit tests
can't generate JUnit report
How to deal with JUnit assertTrue failure scenario using ant
Junit Task in Ant