使用ant执行selenium test suite jar

时间:2012-12-10 16:05:35

标签: ant junit selenium-rc

我有一个使用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>之后。 请帮忙。

0 个答案:

没有答案