0
votes

This is my build.xml file. I am trying to call testNG.xml file to execute it from build.xml but i am getting below error.

 <property name="bin.dir" value="${basedir}/bin" />
 <property name="lib.dir" value="${basedir}/lib" />
 <property name="src.dir" value="${basedir}/src" />
 <property name="res.dir" value="${basedir}/resources" />
 <property name="server.dir" value="${basedir}/server" />

<path id="seleniumautomation.classpath">
  <!-- <pathelement path="${lib.dir}" /> -->
  <fileset dir="${lib.dir}">
   <include name="*.jar" />
   <include name="**/*.jar" />
  </fileset>
  <!--<fileset dir="${basedir}/server"> <include name="*.jar" /> <include 
   name="**/*.jar" /> </fileset> -->
 </path>

<target name="clean">
    <echo>Clean data</echo>
    <delete failonerror="false" dir="lib"/>
</target>

<target name="create" depends="clean">
    <echo>Creating directory.</echo>
    <mkdir dir="lib"/>
</target>

<target name="copy" depends="create">
    <echo>Coping jars</echo>
    <copy todir="lib" overwrite="true">
        <fileset dir="C:\backup\ToolsQA\ProjectThree\JarFiles" includes="**/*.jar" id="id" >      
        </fileset>
    </copy>
</target>

<target name="compile" depends="copy">
    <javac classpathref="seleniumautomation.classpath" includeantruntime="true" srcdir="src" destdir="bin" includes="**/*.java" verbose="true" >
    </javac>
    <echo>Java file compiled Successfully.</echo>
</target>

    <target name="runtests" depends="compile">
        <echo>ABCFD</echo>
          <testng classpathref="seleniumautomation.classpath" useDefaultListeners="true">
            <echo>2431234ABCFD</echo>
            <xmlfileset dir="${basedir}" includes="TestNG.xml" />       
          </testng>
   </target>

BUILD FAILED C:\backup\ToolsQA\ProjectThree\Build.xml:65: Problem: failed to create task or type testng Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types have been declared. Action: Check that any / declarations have taken place.

Please suggest....

1

1 Answers

0
votes

You are missing taskdef tag like:

<taskdef resource="testngtasks" classpath="<Path where testng jar is in >/testng.jar"/>