TestNG Selenium Test通过命令提示符在Ant中失败

时间:2013-05-23 23:18:11

标签: selenium ant testng

我在eclipse中使用Selenium testNG来运行我的测试用例.testNg.xml文件正确执行测试。

但是当我尝试通过ant在命令提示符下运行时,构建成功但测试失败。

发生的一个奇怪的事情是:当我用来测试的驱动程序是HtmlUnitdriver构建成功并且测试通过。但是当我在我的测试用例中使用其他浏览器如firefox,chrome,explorer时,它失败了。

我使用的build.xml是:

<project name="Automation" default="clean" basedir=".">
    <property name="build.dir" value="${basedir}/build"/>
    <property name="lib.dir" value="${basedir}/lib"/>
    <property name="src.dir" value="${basedir}/src"/>

    <target name="setClassPath">
        <path id="classpath_jars">
            <pathelement path="${basedir}/" />
            <fileset dir="${lib.dir}" includes="*.jar" />
        </path>
        <pathconvert pathsep=":" property="test.classpath" refid="classpath_jars" />
    </target>
    <target name="loadTestNG" depends="setClassPath">
        <taskdef resource="testngtasks" classpath="${test.classpath}"/>
    </target>
    <target name="init">
        <mkdir dir="${build.dir}"/>
        <tstamp>
            <format property="timestamp" pattern="dd-MM-yyyy_(HH-mm-ss)"/>
        </tstamp>
        <property name="build.log.dir" location="${basedir}/buildlogs"/>
        <mkdir dir="${build.log.dir}"/>
        <property name="build.log.filename" value="build_${timestamp}.log"/>
        <record name="${build.log.dir}/${build.log.filename}" loglevel="verbose" append="false"/>
        <echo message="build logged to ${build.log.filename}"/>
    </target>
    <target name="clean">
        <echo message="deleting existing build directory"/>
        <delete dir="${build.dir}"/>
    </target>
    <target name="compile" depends="clean,init,setClassPath,loadTestNG">
        <echo message="classpath:${test.classpath}"/>
        <echo message="compiling.........."/>
        <javac destdir="${build.dir}" srcdir="${src.dir}" classpath="${test.classpath}"/>
    </target>
    <target name="runTests" depends="compile">
        <testng classpath="${test.classpath}:${build.dir}">
            <xmlfileset dir="${basedir}" includes="testNg.xml"/>
        </testng>
    </target>

</project>

我感谢任何帮助。

0 个答案:

没有答案
相关问题