@BeforeSuite The annotated method will be run before all tests in this suite have run. 
@AfterSuite The annotated method will be run after all tests in this suite have run. 
@BeforeTest The annotated method will be run before any test method belonging to the classes inside the <test> tag is run. 
@AfterTest  The annotated method will be run after all the test methods belonging to the classes inside the <test> tag have run. 
@BeforeGroups The list of groups that this configuration method will run before. This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked.
@AfterGroups The list of groups that this configuration method will run after. This method is guaranteed to run shortly after the last test method that belongs to any of these groups is invoked. 
@BeforeClass The annotated method will be run before the first test method in the current class is invoked. 
@AfterClass The annotated method will be run after all the test methods in the current class have been run. 
@BeforeMethod The annotated method will be run before each test method. 
@AfterMethod The annotated method will be run after each test method.

Behaviour of annotations in superclass of a TestNG class

The annotations above will also be honored (inherited) when placed on a superclass of a TestNG class. This is useful for example to centralize test setup for multiple test classes in a common superclass.

In that case, TestNG guarantees that the "@Before" methods are executed in inheritance order (highest superclass first, then going down the inheritance chain), and the "@After" methods in reverse order (going up the inheritance chain).

alwaysRun
  • For before methods (beforeSuite, beforeTest, beforeTestClass and beforeTestMethod, but not beforeGroups): If set to true, this configuration method will be run regardless of what groups it belongs to.

  • For after methods (afterSuite, afterClass, ...): If set to true, this configuration method will be run even if one or more methods invoked previously failed or was skipped.

dependsOnGroups The list of groups this method depends on.
dependsOnMethods The list of methods this method depends on.
enabled Whether methods on this class/method are enabled.
groups The list of groups this class/method belongs to.
inheritGroups If true, this method will belong to groups specified in the @Test annotation at the class level.
onlyForGroups Only for @BeforeMethod and @AfterMethod. If specified, then this setup/teardown method will only be invoked if the corresponding test method belongs to one of the listed groups.
@DataProvider

Marks a method as supplying data for a test method. The annotated method must return an Object[][] where each Object[] can be assigned the parameter list of the test method. The @Test method that wants to receive data from this DataProvider needs to use a dataProvider name equals to the name of this annotation.

name:The name of this data provider. If it's not supplied, the name of this data provider will automatically be set to the name of the method.

parallel:If set to true, tests generated using this data provider are run in parallel. Default value is false.

@Factory Marks a method as a factory that returns objects that will be used by TestNG as Test classes. The method must return Object[].
@Listeners

Defines listeners on a test class.

value:The list of variables used to fill the parameters of this method.

@Test

Marks a class or a method as part of the test.

alwaysRun:If set to true, this test method will always be run even if it depends on a method that failed.

dataProvider:The name of the data provider for this test method.

dataProviderClass:The class where to look for the data provider. If not specified, the data provider will be looked on the class of the current test method or one of its base classes. If this attribute is specified, the data provider method needs to be static on the specified class.

dependsOnGroups:The list of groups this method depends on.

dependsOnMethods:The list of methods this method depends on.

description:The description for this method.

enabled:Whether methods on this class/method are enabled.

expectedExceptions:The list of exceptions that a test method is expected to throw. If no exception or a different than one on this list is thrown, this test will be marked a failure.

groups:The list of groups this class/method belongs to.

invocationCount:The number of times this method should be invoked.

invocationTimeOut:The maximum number of milliseconds this test should take for the cumulated time of all the invocationcounts. This attribute will be ignored if invocationCount is not specified.

priority:The priority for this test method. Lower priorities will be scheduled first.

successPercentage:The percentage of success expected from this method

singleThreaded:If set to true, all the methods on this test class are guaranteed to run in the same thread, even if the tests are currently being run with parallel="methods". This attribute can only be used at the class level and it will be ignored if used at the method level. Note: this attribute used to be called sequential (now deprecated).

timeOut:The maximum number of milliseconds this test should take.

threadPoolSize:The size of the thread pool for this method. The method will be invoked from multiple threads as specified by invocationCount. Note: this attribute is ignored if invocationCount is not specified

TestNG-Annotations的更多相关文章

  1. Maven Compilation error [package org.testng.annotations does not exist]

    背景 在执行mvn test的时候,提示package org.testng.annotations does not exist 解决办法 Open pom.xml file. Go to &quo ...

  2. TestNG 入门教程

    原文出处:http://www.cnblogs.com/TankXiao/p/3888070.html 阅读目录 TestNG介绍 在Eclipse中在线安装TestNG 在Eclipse中离线安装T ...

  3. JAVA+Maven+TestNG搭建接口测试框架及实例

    1.配置JDK 见另一篇博客:http://www.cnblogs.com/testlurunxiu/p/5933912.html 2.安装Eclipse以及TestNG Eclipse下载地址:ht ...

  4. testng 失败自动截图

    testng执行case failed ,testng Listener会捕获执行失败,如果要实现失败自动截图,需要重写Listener的onTestFailure方法 那么首先新建一个Listene ...

  5. 两种方式testng dataprovider结合csv做测试驱动

    方式一: 第一.读取csv数据源码 import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream ...

  6. java分享第十九天(TestNg的IReporter接口的使用)

     IReporter接口是干嘛的?就是让用户自定义报告的,很多人想要自定义报告,于是乎找各种插件,比如什么testng-xslt啊,reportng啊,各种配置,最后出来的结果,还不能定制化,但为什么 ...

  7. java分享第十八天-02( java结合testng,利用XML做数据源的数据驱动)

    testng的功能很强大,利用@DataProvider可以做数据驱动,数据源文件可以是EXCEL,XML,YAML,甚至可以是TXT文本.在这以XML为例:备注:@DataProvider的返回值类 ...

  8. APP接口自动化测试JAVA+TestNG(三)之HTTP接口测试实例

    前言     前两篇普及相关基础知识后,本篇主要对举例对国家气象局接口自动化测试进行讲解(Get请求及结果断言),以达到自动化测试入门目的,除了前两篇的一些了解外,需要有一定的JAVA知识(HTTP相 ...

  9. APP接口自动化测试JAVA+TestNG(二)之TestNG简介与基础实例

    前言 继上篇环境篇后,本篇主要对TestNG进行介绍,给出最最基础的两个实例,通过本文后,学会并掌握TestNG测试用例的编写与运行,以及生成美化后的报告.下一篇为HTTP接口实战(国家气象局接口自动 ...

  10. testng教程之testng.xml的配置和使用,以及参数传递

    昨天学习了一下testng基础教程,http://www.cnblogs.com/tobecrazy/p/4579414.html 昨天主要学习的是testng 的annotation基本用法和生命周 ...

随机推荐

  1. XSSer:自动化XSS漏洞检测及利用工具

    转载自FreeBuf.COM XSS是一种非常常见的漏洞类型,它的影响非常的广泛并且很容易的就能被检测到. 攻击者可以在未经验证的情况下,将不受信任的JavaScript片段插入到你的应用程序中,然后 ...

  2. 【AMAD】django-channels -- 为Django带来异步开发

    动机 简介 个人评分 动机 目前web生态的发展带来了很多异步特性,比如websocket.而原生Django并不支持. 简介 django-channels1为Django带来了Websocket, ...

  3. 在VMware上部署MOS(MirantisOpenStack-6.0)搭建全过程

    安装清单 MOS9.0系统镜像 1 MirantisOpenStack-6.0.iso ****首先创建3个仅主机模式网卡, 禁用DHCP,分别配置ip为 /10.20.0.0 /172.16.0.0 ...

  4. vc++中播放声音

    http://www.cnblogs.com/xuemaxiongfeng/articles/2462560.html http://bbs.csdn.net/topics/390729457 htt ...

  5. 最新 光环新网java校招面经 (含整理过的面试题大全)

    从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.优刻得等10家互联网公司的校招Offer,因为某些自身原因最终选择了优刻得.6.7月主要是做系统复习.项目复盘.LeetCo ...

  6. 最新 钢银电商java校招面经 (含整理过的面试题大全)

    从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.钢银电商等10家互联网公司的校招Offer,因为某些自身原因最终选择了钢银电商.6.7月主要是做系统复习.项目复盘.Leet ...

  7. C++多线程基础学习笔记(十)

    一.Windows临界区的基本用法 CRITICAL_SECTION my_winsc;              //定义一个Windows的临界区,相当于一个mutex变量 InitializeC ...

  8. axios拦截器的介绍

    interceptors 拦截器 拦截器一般做什么? 1. 修改请求头的一些配置项 2. 给请求的过程添加一些请求的图标 3. 给请求添加参数 拦截器的基本语法: 拦截器分为全局拦截器和局部拦截器 全 ...

  9. python之并发编程(概念篇)

    一.进程 1.什么是进程 进程是正在进行的一个过程或者一个任务.而负责执行任务的则是cpu. 2.进程与程序的区别 程序并不能单独运行,只有将程序装载到内存中,系统为它分配资源才能运行,而这种执行的程 ...

  10. 数据结构与算法之排序算法(python实现)

    1.冒泡排序 冒泡排序的原理是依次比较相邻的两个数,如果前一个数比后一个数大则交换位置,这样一组比较下来会得到该组最大的那个数,并且已经放置在最后,下一轮用同样的方法可以得到次大的数,并且被放置在正确 ...