您的位置:首页 > 其它

基于Ant+Selenium+TestNG的测试框架配置

2013-09-17 16:01 417 查看
<?xml version="1.0" encoding="UTF-8"?>

<!--This xml file build for Ant,default task "test" executed-->

<project default="run-test">

<property name="Framework-src" value="./src" />

<property name="bin" value="./bin" />

<property name="lib" value="./lib" />

<property name="outputs" value="./report" />

<property name="conf" value="./config" />

<!--Set path-->

<path id="cp">

<fileset dir="${lib}">

<include name="**/*.jar"/>

</fileset>

<pathelement location="${bin}"/>

</path>

<path id="cp.jar">

<fileset dir="${lib}" includes="*.jar"/>

</path>

<!--Compile all resource java file into class file-->

<target name="Compile">

<javac srcdir="${Framework-src}" destdir="${bin}"

classpathref="cp" />

</target>

<!--Define testng task-->

<taskdef name="testngtest" classpathref="cp"

classname="org.testng.TestNGAntTask" />

<!--Define testng target-->

<target name="run_testNG">

<testngtest classpathref="cp"

useDefaultListeners="true"

outputDir="${outputs}">

<!--You can add one or more testcase xml here-->

<xmlfileset dir="${bin}" includes="testng.xml"/>

</testngtest>

</target>

<!--使用生成Excel报告-->

<target name="StartTest">

<delete dir="${outputs}"/>

<copy todir="${outputs}">

<fileset file="${conf}/Report-Template.xls"/>

</copy>

<rename src="${outputs}/Report-Template.xls" dest="${outputs}/Report.xls"/>

<java classname ="jd.main.RunTest" classpathref="cp" />

</target>

<!--使用testng-results.xls美化报告-->

<!--depends="run_testNG"-->

<target name= "transform">

<copy todir="${outputs}">

<fileset file="${conf}/testng-results.xsl"/>

</copy>

<xslt in= "${outputs}/testng-results.xml" style= "${outputs}/testng-results.xsl" out= "${outputs}/index1.html">

<!-- you need to specify the directory here again -->

<classpath refid= "cp.jar" />

<param name="testNgXslt.outputDir" expression="${basedir}/report"/>

<param name="testNgXslt.showRuntimeTotals" expression="true"/>

</xslt>

</target>

<!-- Run Test -->

<target name="run-test" description="Compile;Run TestNG;">

<parallel>

<sequential>

<antcall target="Compile"></antcall>

<antcall target="StartTest"></antcall>

<!-- <antcall target="run_testNG"></antcall>-->

<antcall target="transform"></antcall>

</sequential>

</parallel>

</target>

</project>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: