您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源單元測(cè)試工具 > TestNG
Testng+Reportng+Ant執(zhí)行自動(dòng)化用例
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2016/4/28 10:25:24 ] 推薦標(biāo)簽:單元測(cè)試 自動(dòng)化測(cè)試

  工具:Eclipse、Testng、Reportng、Ant
  場(chǎng)景:通過Ant執(zhí)行Testng用例,并輸出Reportng報(bào)告
  1、編寫ant腳本
<?xml version="1.0"?>
<project name="MySelenium" default="run" basedir=".">
<echo message="import libs" />
<echo>Java-Home: ${java.home}</echo>
<echo>Java-Version: ${java.version}</echo>
<property name="src.dir" value="src est" />
<property name="dest.dir" value="build" />
<property name="dest.report" value="report" />
<path id="run.classpath">
<fileset dir="${basedir}">
<include name="lib/*.jar" />
</fileset>
</path>
<taskdef name="testng" classname="com.beust.testng.TestNGAntTask">
<classpath>
<pathelement location="lib/testng-6.9.9.jar"/>
</classpath>
</taskdef>
<target name="clean">
<delete dir="${dest.dir}" />
</target>
<target name="compile" depends="clean">
<echo message="mkdir" />
<mkdir dir="${dest.dir}" />
<javac target="1.7" srcdir="${src.dir}" destdir="${dest.dir}" encoding="UTF-8" debug="on" includeAntRuntime="false" >
<classpath refid="run.classpath" />
</javac>
</target>
<path id="runpath">
<path refid="run.classpath" />
<pathelement location="${dest.dir}" />
</path>
<target name="run" depends="compile">
<testng classpathref="runpath" outputDir="${dest.report}" haltOnFailure="true" useDefaultListeners="false" listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter,org.testng.reporters.FailedReporter">
<!--<testng classpathref="runpath" outputDir="${dest.report}" haltOnFailure="true" useDefaultListeners="true" >-->
<xmlfileset dir="${basedir}" includes="testng.xml" />
<jvmarg value="-ea" />
</testng>
</target>
</project>
  2、引入需要的jar包


  testng輸出報(bào)告

  好將下面的jar包都引入,不然會(huì)瘋掉的,會(huì)一個(gè)個(gè)報(bào)錯(cuò)提示你
 。ㄆ渲衘xl-2.6.12.jar讀取excel,東面j-1.6.jar讀取xml,沒有用到的可以不加)

上一頁(yè)12下一頁(yè)
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd