1

我有一个使用 JUNIT 测试用例的 Selenium RC 测试项目。我已经制作了一个 JAR 文件,我正在通过 ANT 构建文件执行该 JAR:

我的 ant 文件如下所示:

*

<project name="test" default="run-all" basedir=".">
    <property name="src" value="./src" />
    <property name="lib" value="./lib" />
    <property name="bin" value="./bin" />
    <property name="report" value="./report" />
    <path id="test.classpath">
        <pathelement location="${bin}" />
        <fileset dir="${lib}">
            <include name="**/*.jar" />
        </fileset>
    </path>
    <target name="init">
        <delete dir="${bin}" />
        <mkdir dir="${bin}" />
    </target>
    <target name="exec" depends="init">
        <delete dir="${report}" />
        <mkdir dir="${report}" />
            <mkdir dir="${report}/xml" />
        <junit printsummary="yes" haltonfailure="no">
            <batchtest fork="yes" todir="${report}/xml">
            <resources>
               <zipfileset src="BVTTest.jar" includes="**/*TestSuite.class"/>
            </resources> 

            </batchtest>
            <classpath>
            <fileset dir="">
                <include name="**/*.jar" />
            </fileset>
            </classpath>
        </junit>

        <junitreport todir="${report}">
            <fileset dir="${report}/xml">
                <include name="TEST*.xml" />
            </fileset>
            <report format="frames" todir="C:/eclipse/html" />
        </junitreport>
    </target>
    <target name="start-selenium-server">
            <java jar="selenium-server-standalone-2.25.0.jar" fork="true" spawn="true">
                <arg line="-timeout 30" />
            </java>
        </target>
    <target name="browse">
        <exec executable="C:\Program Files\Internet Explorer\iexplore.exe">
          <arg value="C:/eclipse/html/index.html"/>
        </exec>
      </target>
    <target name="stop-selenium-server">
            <get taskname="selenium-shutdown" 
                src="http://localhost:4444/selenium-server/driver/?cmd=shutDown" 
                dest="result.txt" 
                ignoreerrors="true" />
            <echo message="selenium server stopped succesfully"/>
        </target>
    <target name="run-all">
            <parallel>
                <antcall target="start-selenium-server">
                </antcall>
                <sequential>
                    <echo taskname="waitfor" message="Wait for proxy server launch" />
                    <waitfor maxwait="1" maxwaitunit="minute" checkevery="100">
                        <http url="http://localhost:4444/selenium-server/
                            driver/?cmd=testComplete" />
                    </waitfor>
                    <antcall target="exec">
                    </antcall>
                    <antcall target="stop-selenium-server">
                    </antcall>
                    <antcall target="browse">
                        </antcall>
                </sequential>
            </parallel>
        </target>
</project>

*

它的作用是跳过<junit>; 然后<mkdir>直接跳转到<junitreport>. 请帮忙。

4

0 回答 0