jeudi 28 février 2019

Generating test reports with Ant and TestNG with selenium webdriver

I using file "build.xml" for generating the reports for the tests but when i compile my file on cmd then it shows build successful but when i run my file using "ant run" command on cmd then it shows an error "no suites classes methods or jar file was specified" Please check my code: I used selenium webdriver with java and also link all the required jar files to the build.xml file

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

<project name="TestNG Module" default="usage" basedir=".">  

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

   <property name="test.dest" value="${ws.home}/build"/>
    <property name="test.src" value="${ws.home}/src"/>
    <property name="ng.result" value="test-output"/>
    <property name="ws.jars" value="E:\New folder\TestNG"/>



    <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="run" depends="compile">
        <testng classpath="${test.classpath}:${test.dest}" suitename="suite1">  
            <xmlfileset dir="${ws.home}" includes="testng.xml"/>
        </testng>
     </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>
        <taskdef resource="testngtask" classpath="testng.jar"/>
       <taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath>
<pathelement location="E:\New folder\TestNG jars\testng-6.8.5.jar"/>
</classpath>
</taskdef>
    </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>

    <!-- run -->



    <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="makexsltreports">
            <mkdir dir="${ws.home}/XSLT_Reports/output"/>

            <xslt in="${ng.result}/testng-results.xml" style="src/xslt/testng-results.xsl"
                  out="${ws.home}/XSLT_Reports/output/index.html" classpathref="test.c" processor="SaxonLiaison">
                <param name="testNgXslt.outputDir" expression="${ws.home}/XSLT_Reports/output/"/>
                <param name="testNgXslt.showRuntimeTotals" expression="true"/>
            </xslt>
        </target>



</project>

Aucun commentaire:

Enregistrer un commentaire