While running my test through ant, test priority order defined in test annotations is not preserved. It works fine when I run it through testng.xml

I have three testng class files having 100 test cases. I have defined test priority using @test(priority=n) in all of them.   My issue is when I run them through ant , build.xml the priority order is not preserved and it executes the test randomly. However if I execute testng.xml then it works fine. Can you help me here. I have pasted build.xml and testng.xml both.   build.xml is this: ===================

 

<?xml version=”1.0″ encoding=”UTF-8″?> <project name= “Pouring Pounds Automation Framework” basedir=”.” default=”testResult” > <property name=”src.dir” value=”src” /> <property name=”lib.dir” value=”lib” /> <property name=”build.dir” value=”build” /> <property name=”classes.dir” value=”classes” /> <property name=”reports.dir” value=”REPORTS” /> <property name=”testNG.report” value=”REPORTS/TESTNG-REPORTS” /> <property name=”suite.dir” value=”suite” /> <!– Class-Path –> <path id=”classpath”> <pathelement location=”${classes.dir}”/> <fileset dir=”${lib.dir}” includes=”*.jar”/> </path> <!– Delete directories that are not needed –> <target name=”delete-dir” > <delete dir=”${build.dir}”/> <delete dir=”${reports.dir}”/> <delete dir=”${classes.dir}”/> <echo> /* Deleted existing Compiled Directory Classes */ </echo> </target> <!– Create Directories –> <target name=”create-source-dir” depends=”delete-dir”> <mkdir dir=”${classes.dir}”/> <mkdir dir=”${reports.dir}”/> <mkdir dir=”${testNG.report}”/> <echo> /* Created Directories */ </echo> </target> <!– Compiling Tests –> <target name=”compile-classes” depends=”create-source-dir”> <javac destdir=”${classes.dir}” includeantruntime=”false” debug=”true” srcdir=”${src.dir}”> <classpath refid=”classpath”/> </javac> <echo> /* Compiled Directory Classes */ </echo> </target> <!– Running Tests and TestNG report generation –> <target name=”testNGreport” depends=”compile-classes”> <taskdef resource=”testngtasks” classpathref=”classpath”/> <testng classpathref=”classpath” outputDir=”${testNG.report}” haltOnfailure=”false”> <xmlfileset dir=”.” includes=”config/testng.xml” /> </testng> <echo> /* Run Directory Classes */ </echo> </target> <target name=”testResult” depends=”testNGreport”> <xslt in=”${basedir}/REPORTS/TESTNG-REPORTS/testng-results.xml” style=”${basedir}/config/testng-results.xsl” out=”${basedir}/REPORTS/FORMATTED-REPORTS/MainReport.html” processor=”SaxonLiaison”> <param expression=”${basedir}/REPORTS/FORMATTED-REPORTS” name=”testNgXslt.outputDir” /> <param expression=”true” name=”testNgXslt.sortTestCaseLinks” /> <param expression=”FAIL,SKIP,PASS,CONF,BY_CLASS” name=”testNgXslt.testDetailsFilter” /> <param expression=”true” name=”testNgXslt.showRuntimeTotals” /> <classpath refid=”classpath”> </classpath> </xslt> </target> </project>     testNG.XML is this: ============== <?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”> <suite name=”Suite”> <test name=”Test1″ preserve-order=”true”> <classes> <class name=”pouringPounds.testCases.JoinFreeTest_Desktop”/> <class name=”pouringPounds.testCases.SignIn_Desktop”/> <class name=”pouringPounds.testCases.ContactUs_Desktop”/> </classes> </test> <!– Test1 –> </suite> <!– Suite –>

Default Asked on April 25, 2017 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)

    Anyone : Can you help here please.

    Default Answered on April 26, 2017.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.