1

我编写了几个 selenium 脚本(Java)并使用 sikuli 来验证图像是否存在。当我通过 Eclipse/TestNG 运行测试时它运行良好,但使用 Ant 时出现以下错误:

[testng] [error] resources/x.png 看起来像一个文件,但在磁盘上找不到。假设它是文本。

以下是我的 build.xml,如果我可以提供更多信息,请告诉我。

<project name="test" default="test">
    <property name="src.dir" location="src" />
<property name="build.dir" location="build" />
<property name="dist.dir" location="dist" />
<property name="lib.dir" location="lib" />

    <path id="build.classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar" />
        </fileset>
    </path>

    <target name="clean">
    <delete dir="${build.dir}" />
</target>

    <target name="makedir" depends="clean">
    <mkdir dir="${build.dir}" />
</target>

    <!-- Compiles the java code -->
<target name="compile" depends="clean, makedir">
    <javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="build.classpath"/>      
</target>

<!--Creates the deployable jar file  -->
<target name="jar" depends="compile">
    <jar destfile="${dist.dir}\build.test.ant.jar" basedir="${build.dir}">
        <manifest>
            <attribute name="Main-Class" value="test.Main" />
        </manifest>
    </jar>
</target>

    <taskdef resource="testngtasks" classpath="${lib.dir}/testng-6.5.2.jar"/>

    <target name="test" depends="jar">
      <testng 
   classpath="${build.dir}:${lib.dir}/selenium-java-2.24.1.jar:${lib.dir}/selenium-server-standalone-2.24.1.jar:${lib.dir}/sikuli-script.jar"
   outputDir="${testng.report.dir}"
   testname="test1">
       <xmlfileset dir="." includes="testng.xml" />
      </testng>
      <fail message="BUILD FAILURE" if="failed" />
    </target>

</project>
4

0 回答 0