TestNG官方网站:
http://testng.org/doc/documentation-main.html
官方文档:
/** * */ package com.easyway.testng.junit; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import org.testng.IMethodInstance; import org.testng.IMethodInterceptor; import org.testng.ITestContext; import org.testng.annotations.Test; /** * @author longgangbai 2013-11-29 下午4:31:40 * */ public class MyMethodInterceptor implements IMethodInterceptor { /* * (non-Javadoc) * * @see org.testng.IMethodInterceptor#intercept(java.util.List, * org.testng.ITestContext) */ @Override public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) { List<IMethodInstance> result = new ArrayList<IMethodInstance>(); for (IMethodInstance m : methods) { Test test = m.getMethod().getConstructorOrMethod().getMethod() .getAnnotation(Test.class); Set<String> groups = new HashSet<String>(); for (String group : test.groups()) { groups.add(group); } System.out.println("groups +"+groups ); if (groups.contains("fast")) { result.add(0, m); } else { result.add(m); } } return result; } }
/** * */ package com.easyway.testng.junit; import org.testng.annotations.Listeners; import org.testng.annotations.Test; /** * 5.17.1 - Specifying listeners with testng.xml or in JavaHere is how you can define listeners in your testng.xml file: view sourceprint?<suite> <listeners> <listener class-name="com.example.MyListener" /> <listener class-name="com.example.MyMethodInterceptor" /> </listeners> ... Or if you prefer to define these listeners in Java: view sourceprint?@Listeners({ com.example.MyListener.class, com.example.MyMethodInterceptor.class }) public class MyTest { // ... } The @Listeners annotation can contain any class that extends org.testng.ITestNGListener except IAnnotationTransformer and IAnnotationTransformer2. The reason is that these listeners need to be known very early in the process so that TestNG can use them to rewrite your annotations, therefore you need to specify these listeners in your testng.xml file. Note that the @Listeners annotation will apply to your entire suite file, just as if you had specified it in a testng.xml file. If you want to restrict its scope (for example, only running on the current class), the code in your listener could first check the test method that's about to run and decide what to do then. * @author longgangbai * 2013-11-29 下午4:12:17 * */ @Listeners({ MyMethodInterceptor.class }) public class MyListenerTest { @Test public void test1() { System.out.println("=================test1============="); } @Test public void test2() { System.out.println("=================test2============="); } }
相关推荐
TestNG中文手册及学习笔记,包括:环境配置、详细使用说明及实例。
1、testng测试报告模板BeautifulReport 2、testng.xml文件
让我们调用使用testng.xml文件。创建一个XML文件名称testng.xml C:\ > TestNG_WORKSPACE 执行测试用例(s) <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > </suite> 第7步:检查结果 ...
学习笔记资料来源:http://www.yiibai.com/testng/;从易佰TestNG教程整理,包括概念介绍,代码实例。
TestNG官方文档中文版,详细的介绍了testng的使用指南。
testng-xslt-1.1.2.zip
讲解如何使用Selenium 和 TestNG 进行编程式测试
TestNG-Abbot源自于两个成功的开发人员测试框架的结合:Abbot和TestNG。Abbot是一种JUnit扩展框架,主要目的...一旦理解了它,您会发现将GUI组件隔离并使用框架所含的极其方便的fixture对象对其进行验证是多么地简单。
1.下载testNG 离线安装包【eclipse-testng离线包】,并解压。 2.将解压后的文件..\eclipse-testng离线包\features\目录下的文件夹org.testng.eclipse_6.11.0.201703011520放到eclipse安装路径下的features目录下 3....
testNG 自动化测试工具 工具类 testng-6.3.jar
1. 将解压后的文件..\eclipse-testng离线包\features\org.testng.eclipse_6.9.9.201510270734 文件夹 放到 eclipse--》features目录下 2. 将解压后的文件..\eclipse-testng离线包\plugins\org.testng.eclipse_6.9...
testng-6.8.8
2017年6月5日记:在学习直接用手工执行testng.xml时,得到以下教训: 1、如果写批处理调用,环境变量的末尾必须以分号结束,否则调试气死你也搞不定啥原因,控制台就一句话,找不到类;
1. 将解压后的文件..\eclipse-testng离线包\features\org.testng.eclipse_6.9.9.201510270734 文件夹 放到 eclipse--》features目录下 2. 将解压后的文件..\eclipse-testng离线包\plugins\org.testng.eclipse_...
testng-6.9-10 jar包
TestNG官方文档中文版.pdf TestNG 图解说明.pdf
[Packt Publishing] TestNG 初学者指南 (英文版) [Packt Publishing] TestNG Beginner's Guide (E-Book) ☆ 图书概要:☆ Write robust unit and functional tests with the power of TestNG Overview Step-by-...
testng目前需要jdk1.8,此jar包支持1.6
1.下载testNG 离线安装包【eclipse-testng离线包】,并解压。 2.将解压后的文件..\eclipse-testng离线包\features\目录下的文件夹org.testng.eclipse_6.9.8.201510130443放到eclipse安装路径下的features目录下 3.将...
接口测试,eclipse testng离线包是eclipse的插件,怎么在Eclipse下配置TestNG环境。 ... ... 3. 配置Java环境变量: JAVA_HOME,PATH,CLASSPATH 4. 安装Eclipse TestNG插件 ...6. 在Java Project中使用TestNG测试