1.定义TestNG 的配置文件

<test name="exampletest1">
        <classes>

                         <!--1.只执行com.testng.TestGroup的方法testPrintMessage,不执行testPrintMessage1 -->
            <class name="com.testng.TestGroup">
                <methods>
                    <include name="testPrintMessage" />
                  <exclude name="testPrintMessage1"/>
                </methods>
            </class>
            <!--2.按顺序执行TankLearn2.Learn.TestNGLearn1 类的三个方法-->
       <class name="TankLearn2.Learn.TestNGLearn1">
<methods>
<include name="TestNgLearn3" />
<include name="TestNgLearn1" />
<include name="TestNgLearn2" />
</methods>
</class>

</classes>        
    </test>

2.分组执行

@Test(groups = { "BeiJing"})
public void getBeiJing_Succ() throws IOException{
     exp_city="北京";
     cityCode="101010100";
     resultCheck(cityCode, exp_city);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1">
    <test name="test1">
        <groups>
            <run> 定义执行的组名及顺序
                <include name="BeiJing" />
......
            </run>
        </groups>
        <classes>  定义class
            <class name="findyou.testcase.test1" />  
        </classes>  
    </test>
</suite>

3.组中组

 <test name="test1">
<groups>
<define name="all"> 定义执行的组和不执行的组
<include name="functest"/>
<include name="checkintest"/>
        <exclude name="functest"/>
</define>
<run> 执行组
<include name="all"/>
</run>
</groups>
<classes>
<class name="GroupTestExample" />
</classes>
</test>

4.自定义参数1

@Test
  @Parameters({ "cityCode_str", "exp_city_str" })
  public void resultCheckp(String cityCode_str, String exp_city_str) throws IOException{    
    resultCheck( cityCode_str,  exp_city_str);
  }

<parameter name="country" value="中国" />  公用参数,适用所有

 <test name="resultCheckp2">
     <parameter name="cityCode_str" value="101010100" />  适用参数
     <parameter name="exp_city_str" value="北京" />
     <classes>
        <class name="findyou.testcase.test1">
           <methods>
              <include name="resultCheckp" />
           </methods>
         </class>
      </classes>
    </test>   

5.依赖测试

   public class DependsTest {
    @Test
    public void setupEnv(){
        System.out.println("this is setup Env");
    }
    @Test(dependsOnMethods = {"setupEnv"})
    public void testMessage(){
        System.out.println("this is test message");
    }
  }

6.生命周期

待续

testng入门_单元测试的更多相关文章

  1. Spring_MVC_教程_快速入门_深入分析

    Spring MVC 教程,快速入门,深入分析 博客分类: SPRING Spring MVC 教程快速入门  资源下载: Spring_MVC_教程_快速入门_深入分析V1.1.pdf Spring ...

  2. 【笔记目录2】【jessetalk 】ASP.NET Core快速入门_学习笔记汇总

    当前标签: ASP.NET Core快速入门 共2页: 上一页 1 2  任务27:Middleware管道介绍 GASA 2019-02-12 20:07 阅读:15 评论:0 任务26:dotne ...

  3. TestNG 入门教程【转】

    TestNG 入门教程[转] 国庆7天假期,大部分朋友都出去旅游了,微信圈里全是晒旅游的照片, 东南亚游,欧洲游呀,真是羡慕呀. 悲惨的我只去了上海野生动物园, 在家休息,利用这段假期,把之前学过的东 ...

  4. 09_android入门_采用android-async-http开源项目的GET方式或POST方式实现登陆案例

    根据08_android入门_android-async-http开源项目介绍及使用方法的介绍,我们通过最常见的登陆案例进行介绍android-async-http开源项目中有关类的使用.希望对你学习 ...

  5. 09_android入门_採用android-async-http开源项目的GET方式或POST方式实现登陆案例

    依据08_android入门_android-async-http开源项目介绍及用法的介绍,我们通过最常见的登陆案例进行介绍android-async-http开源项目中有关类的使用.希望对你学习an ...

  6. testng入门教程16数据驱动(把数据写在xml)

    testng入门教程16数据驱动(把数据写在xml) testng入门教程16数据驱动(把数据写在xml)把数据写在xml文件里面,在xml文件右键选择runas---testng执行 下面是case ...

  7. testng入门教程12 TestNG执行多线程测试

    testng入门教程 TestNG执行多线程测试 testng入门教程 TestNG执行多线程测试 并行(多线程)技术在软件术语里被定义为软件.操作系统或者程序可以并行地执行另外一段程序中多个部分或者 ...

  8. 07_android入门_採用HttpClient的POST方式、GET方式分别实现登陆案例

    1.简单介绍 HttpClient 是 Apache Jakarta Common 下的子项目,能够用来提供高效的.最新的.功能丰富的支持 HTTP 协议的客户端编程工具包,而且它支持 HTTP 协议 ...

  9. IDEA 单元测试testng入门及testng.xml

    直接进入正题: 1.TestNG的运行方式如下: With a testng.xml file 直接run as test suite With ant 使用ant From the command ...

随机推荐

  1. [BZOJ1833][ZJOI2010]Count数字计数(DP)

    数位DP学傻了,怎么写最后都写不下去了. 这题严格上来说应该不属于数位DP?只是普通DP加上一些统计上的判断吧. 首先复杂度只与数的位数$\omega$有关,所以怎么挥霍都不会超. f[i][j][k ...

  2. 【手动开栈】【dfs序】【树状数组】【Tarjan】bzoj2819 Nim

    考虑树状数组区间修改(只对其子树的答案有影响)点查询,每个点记录的是它到根路径上的权值异或和. 答案时query(L)^query(R)^a[lca]. 这种方法在支持区间加法.减法的树上询问的时候可 ...

  3. Eclipse快速补全快捷键Ctrl+1修改为Android Studio的Alt+Enter

    步骤: Window ->Preferences->key-> type filter text 下输入quick fix(这个是快速补全的快捷键)改为Alt+Enter 下面的wh ...

  4. 利用hsdis和JITWatch查看分析HotSpot JIT compiler生成的汇编代码

    http://blog.csdn.net/hengyunabc/article/details/26898657

  5. 【spring boot】4.spring boot配置多环境资源文件

    一个spring boot 项目在开发环境.测试环境.生产环境下,好多的配置都是不尽相同的.所以配置多分的资源文件,仅仅在部署在不同环境的时候,选择激活不同的资源文件就可以实现多环境的部署. 项目结构 ...

  6. js各种验证总结

    1.邮箱验证 function isEmail(str){ var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1 ...

  7. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:3.安装Oracle RAC-3.2.安装 cvuqdisk 软件包

    3.2.安装 cvuqdisk 软件包 3.2.1. 准备Oracle  Grid安装包 上传Grid .Oracle 安装文件: sftp> put E:\Software\linux.x64 ...

  8. shell脚本编写注意事项

    shell中赋值变量时不能有空格 之前写python写习惯了 test = ‘free -m’ 在shell中不能有空格 test='free -m' 而且使用管道符之前要留空格 test='free ...

  9. jquery 中attr和prop的区别

    在jQuery API中也有专门解释: Attributes VS. Properties 在一些特殊的情况下,attributes和properties的区别非常大.在jQuery1.6之前,.at ...

  10. 虚拟机oracle virtualbox 上安装centos6.5 网络设置

    上篇文章写到,在虚拟机上安装centos6.5,结果依照文章非常顺利的安装了,可是用yum安装软件的时候.报错,源有问题,不能下载,然后ping一下摆渡.非常悲催 dns解析不了,cat /etc/r ...