0
votes

When I run Test NG test using testng.xml, it runs fine but if i run testng.xml using ant (Build.xml), it gives an error Cannot fine class in classpath

Testng.xml:-

?xml version="1.0" encoding="UTF-8"?>

Build.xml:-

<xmlfileset dir="." includes="testng.xml"/> 

1
Which class is not - testng or test class? Can you post a bit more of the build.xml snippet? - Raghuram
I had put he entire file i dont know why its not displayed any ways putting it again - TestUser
<target name="testng"> <property name="test.base.output.dir" location="testng_output"/> <mkdir dir="${test.base.output.dir}"/> <tstamp><format property="DAY_TIME_NOW" pattern="yyyy-MM-dd_HH.mm.ss" /></tstamp> <property name="test.output.dir" location="${test.base.output.dir}/testng_output_${DAY_TIME_NOW}"/> <mkdir dir="${test.output.dir}"/> <taskdef name="testng" classname="org.testng.TestNGAntTask" > <classpath> <pathelement location="../lib/testng-5.12.1.jar"/> </classpath></taskdef> <testng outputdir="${test.output.dir}" > <xmlfileset dir="." includes="testng.xml"/> </testng> </target> - TestUser
xml code seems to be OK. Please check your configuration - Ripon Al Wasim

1 Answers

1
votes
<xmlfileset dir="." includes="testng.xml">

Certainly the error is in this line.Its looking for compiled classes in the base directory(dir=".").point dir to bin folder where the compiled classes would be usually or wherever you have kept the compile classes.here an example:

<xmlfileset dir="${basedir}/bin" includes="testng.xml">