Почему Ant выполняет тестовые классы, определенные в testng.xml в неправильном порядке? - PullRequest
0 голосов
/ 21 ноября 2011

Я получил следующие testng.xml и build.xml:

<suite name="My test suite" preserve-order="true">
 <parameter name="a" value="abcd"/>
 <parameter name="b" value="efgh"/>

<test name="testing">
<classes>
   <class name="test.First"/>
   <class name="test.Second">
    <methods>
        <exclude name="method1"/>
    </methods>
   </class>
   <class name="test.Third"/>
   <class name="test.Forth">
        <methods>
            <exclude name="method3"/>
        </methods>
   </class> 
   <class name="test.Fifth"/>
   <class name="test.Sixth"/>
</classes>

Если я выполняю testng.xml внутри своей IDE, классы вызываются в следующем порядке: First, Second, ..., Sixth Но если я запускаю следующий build.xml с ANT, классы вызываются в неправильном порядке, например: Шестой, Четвертый, Пятый, Второй, Третий, Первый. Порядок меняется. Я думал, что с TestNG это не должно происходить?

build.xml:

<project basedir="." default="build" name="Dummy">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="MyEclipse"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.6"/>
<property name="source" value="1.6"/>
<path id="classpath">
    <pathelement location="bin"/>
    <pathelement location="../selenium-server-standalone-2.10.0.jar"/>
    <pathelement location="testng.jar"/>
</path>
<target name="init">
    <mkdir dir="bin"/>
    <copy includeemptydirs="false" todir="bin">
        <fileset dir="src">
            <exclude name="**/*.launch"/>
            <exclude name="**/*.java"/>
        </fileset>
    </copy>
</target>
<target name="clean">
    <delete dir="bin"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="init" name="build">
    <echo message="${ant.project.name}: ${ant.file}"/>
    <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}" encoding="iso-8859-1">
        <src path="src"/>
        <classpath refid="classpath"/>
    </javac>
</target>
<taskdef name="testng"
      classname="org.testng.TestNGAntTask"
      classpathref="classpath"/>
<target name="test" depends="build">
    <echo message="running tests"/>
    <testng classpathref="classpath" outputdir="testng_output">
         <xmlfileset dir="bin" includes="testng.xml"/>
    </testng>
</target>

Почему заказ неправильный?

Буду признателен за помощь.

1 Ответ

2 голосов
/ 21 ноября 2011

Привет, возможно, вы используете две разные версии testng, одна из которых включена в Eclipse Plugin, а другая - в вашем classpath.Произошла ошибка (http://code.google.com/p/testng/source/detail?r=966) в атрибуте preserve-order, возможно, у вас есть ошибочная версия в вашем classpath. Попробуйте обновить версию testng, указанную сценарием build.xml

...