一、环境搭建
安装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下面)
创建类和方法:
import org.testng.annotations.Test; 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 文件:
//
ant build.xml文件内容:
//
JENKINS引入SVN下载工程包,编译运行:
SVN配置:
ANT配置:
报告输出:
(JENKINS安装TESTNG report 插件)
jenkins console执行报告输出,基本上到这一步就成功了。
再看TESTNG插件生成的TESTNG报告: