一、环境搭建

1. 安装testNG插件到eclipse.

-) 选择菜单 Help /Software updates / Find and Install.

-) 点击add button然后在location中输入http://beust.com/eclipse/

-) 确定后会自动安装testNG插件。

二.包的引入 WebDriver包:selenium-server-standalone.jar

testng 包: testng-6.8.jar

reportng包:reporting.jar,velocity-dep.jar

ant包:ant-contrib.jar

三、新建一个testNG工程:(手动创建lib文件夹,需要把以上三个JAR包放在lib下面)

创建类和方法:

public class test {
  @Test(groups="init")
  public void f() {
  System.out.println("This is test f" );
  }
  @Test(groups="init")
  public void g() {
  System.out.println("This is test g" );
  }
  @Test(dependsOnGroups="init",groups="proccess")
  public void h() {
  System.out.println("This is test h " );
  }
  @Test(dependsOnGroups="init",groups="proccess")
  public void i() {
  System.out.println("This is test i" );
  }
}
testng.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="tests" thread-count="1">
  <test name="test">
  <parameter name = "driverType" value = "1"/>
  <classes>
  <!--测试类-->
      <class name="test"/>
      <class name="login"/>
    </classes>
  <groups>
  <run>
  <!--测试执行用例组合-->
  <include name="proccess"/>
  <include name="login"/>
  </run>
  </groups>
  </test> <!-- Test -->
</suite> <!-- Suite -->

ant build.xml文件内容:

<project name="TestNGTest" default="test" basedir=".">
<!-- Define <testng> task -->
  <taskdef name="testng" classname="org.testng.TestNGAntTask">
    <classpath>
      <pathelement location="lib/testng-6.8.jar"/>
    </classpath>
  </taskdef>
   <property name="testdir" location="test" />
   <property name="srcdir" location="src" />
   <property name="libdir" location="lib" />
   <property name="full-compile" value="true" />
   <path id="classpath.base"/>
   <path id="classpath.test">
       <fileset dir="${libdir}">
         <include name="**/*.jar" />
      </fileset>
      <pathelement location="${testdir}" />
      <pathelement location="${srcdir}" />
      <path refid="classpath.base" />
   </path>
   <target name="clean" >
      <delete verbose="${full-compile}">
         <fileset dir="${testdir}" includes="**/*.class" />
      </delete>
   </target>
   <target name="compile" depends="clean">
      <javac srcdir="${srcdir}" destdir="${testdir}"
         verbose="${full-compile}">
         <classpath refid="classpath.test"/>
      </javac>
   </target>
   <target name="test" depends="compile">
<testng outputdir="${testdir}" classpathref="classpath.test">
      <xmlfileset dir="${srcdir}">
      <include name="suite.xml"/>
      </xmlfileset>
    </testng>
   </target>
</project>
 
 

JENKINS引入SVN下载工程包,编译运行:

SVN配置:

![](http://images2015.cnblogs.com/blog/816853/201611/816853-20161104112845361-224894314.png)

ANT配置:

![](http://images2015.cnblogs.com/blog/816853/201611/816853-20161104112913033-1089837005.png)

报告输出:

(JENKINS安装TESTNG report 插件) jenkins console执行报告输出,基本上到这一步就成功了。

![](http://images2015.cnblogs.com/blog/816853/201611/816853-20161104113451455-1967450719.png)

再看TESTNG插件生成的TESTNG报告:

![](http://images2015.cnblogs.com/blog/816853/201611/816853-20161104113218971-618336380.png)

最新文章

  1. oracle plsql 无法连接 报 ORA-12560: TNS:protocol adapter error
  2. php-简单对称加密算法和字符串与十六进制之间的互转函数
  3. Azure Virtual Machine 之 如何利用Management Class Libraries 创建VM
  4. 【转载】MySQL启多个实例
  5. python——代码编码格式转换
  6. SVN服务端启动解决方案(2013-12-10 记)
  7. 操作符重载.xml
  8. C语言的可变参数
  9. 一步步搭建最简单oauth2.0认证和授权
  10. UESTC 1599 wtmsb【优先队列+排序】
  11. XGBoost模型的参数调优
  12. python爬取京东价格
  13. IOC容器特性注入第六篇:利用MVC注入点,把容器启动
  14. POJ1659 Frogs&#39; Neighborhood(青蛙的邻居) Havel-Hakimi定理
  15. Codeforces 834D - The Bakery(dp+线段树)
  16. ArcGIS 复制要素
  17. .net core 2.2 部署CentOS7(2)给虚拟机安装CentOS7
  18. SEDA架构程序实现
  19. @slf4j注解找不到 log 变量
  20. [SCOI2010]传送带 三分法

热门文章

  1. 【JZOJ4810】【NOIP2016提高A组五校联考1】道路规划
  2. JavaScript--轮播图_带计时器
  3. shell日常使用整理
  4. SaaS加速器II 能力中心:互利互补 共享商业红利
  5. POJ-3186_Treats for the Cows
  6. js获取屏幕相关值
  7. MySQL性能分析, mysql explain执行计划详解
  8. @codeforces - 913F@ Strongly Connected Tournament
  9. @雅礼集训01/13 - T1@ union
  10. Android教程 -04 启动其它Activity,静态工厂设计模式传递数据