TestNG关键字和testNG.xml结构学习
转自官网:http://testng.org/doc/documentation-main.html#test-results
TestNG关键字
|
@BeforeSuite |
@BeforeSuite: The annotated method will be run before all tests in this suite have run. to the classes inside the <test> tag is run. to the classes inside the <test> tag have run. This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked. This method is guaranteed to run shortly after the last test method that belongs to any of these groups is invoked. the current class is invoked. current class have been run. |
testNG.xml结构
The concepts used in this documentation are as follows:
- A suite is represented by one XML file. It can contain one or more tests and is defined by the <suite> tag.
- A test is represented by <test> and can contain one or more TestNG classes.
- A TestNG class is a Java class that contains at least one TestNG annotation. It is represented by the <class> tag and can contain one or more test methods.
- A test method is a Java method annotated by @Test in your source.
Here is an example testng.xml file:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="Suite1" verbose="1" >
<test name="Nopackage" >
<classes>
<class name="NoPackageTest" />
</classes>
</test> <test name="Regression1">
<classes>
<class name="test.sample.ParameterSample"/>
<class name="test.sample.ParameterTest"/>
</classes>
</test>
</suite>
You can specify package names instead of class names:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="Suite1" verbose="1" >
<test name="Regression1" >
<packages>
<package name="test.sample" />
</packages>
</test>
</suite>
In this example, TestNG will look at all the classes in the package test.sample and will retain only classes that have TestNG annotations.
You can also specify groups and methods to be included and excluded:
public class Test1 {
@Test(groups = { "functest", "checkintest" })
public void testMethod1() {
}
@Test(groups = {"functest", "checkintest"} )
public void testMethod2() {
}
@Test(groups = { "functest" })
public void testMethod3() {
}
}
<test name="Regression1">
<groups>
<run>
<exclude name="brokenTests" />
<include name="checkinTests" />
</run>
</groups> <classes>
<class name="test.IndividualMethodsTest">
<methods>
<include name="testMethod" />
</methods>
</class>
</classes>
</test>
You can also define new groups inside testng.xml and specify additional details in attributes, such as whether to run the tests in parallel, how many threads to use, whether you are running JUnit tests, etc...
By default, TestNG will run your tests in the order they are found in the XML file. If you want the classes and methods listed in this file to be run in an unpredictible order, set the preserve-order attribute to false
<test name="Regression1" preserve-order="false">
<classes> <class name="test.Test1">
<methods>
<include name="m1" />
<include name="m2" />
</methods>
</class> <class name="test.Test2" /> </classes>
</test>
Please see the DTD for a complete list of the features, or read on.
TestNG关键字和testNG.xml结构学习的更多相关文章
- testng教程之testng.xml的配置和使用,以及参数传递
昨天学习了一下testng基础教程,http://www.cnblogs.com/tobecrazy/p/4579414.html 昨天主要学习的是testng 的annotation基本用法和生命周 ...
- Ant学习-002-ant 执行 TestNG 测试用例时 [testng] java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException 解决方案
上篇文章中概述了 Ant windows 环境的基本配置,此文讲述在初次使用的过程中遇到的问题. 今天通过 ant 执行 TestNG 测试用例时,执行报错,相应的错误信息如下所示: Buildfil ...
- IDEA 单元测试testng入门及testng.xml
直接进入正题: 1.TestNG的运行方式如下: With a testng.xml file 直接run as test suite With ant 使用ant From the command ...
- maven + appium + testng + java之pom.xml
参考来源:<https://search.maven.org/remotecontent?filepath=io/appium/java-client/3.3.0/java-client-3.3 ...
- Java - Test - TestNG: Idea 引入 testng.xml 自动生成插件
1. 概述 Idea 引入自动生成 testng.xml 插件 自动生成 testng.xml 2. 背景 testng 调试 调试 testng, 主要是这两种方法 ide 下直接执行测试 方法 类 ...
- APP接口自动化测试JAVA+TestNG(二)之TestNG简介与基础实例
前言 继上篇环境篇后,本篇主要对TestNG进行介绍,给出最最基础的两个实例,通过本文后,学会并掌握TestNG测试用例的编写与运行,以及生成美化后的报告.下一篇为HTTP接口实战(国家气象局接口自动 ...
- xml基础之二(XML结构【2】)DTD文档模版
xml基础之二(XML结构[2])DTD文档模版 xml 模板 文档结构 我们知道XML主要用于数据的存储和传输,所以无论是自定义还是外部引用DTD模板文档,都是为了突出数据的存储规范.DTD(文档 ...
- XML基础学习01
XML学习 1:XML:可扩展的标识语言,是一种描述结构数据的格式,简化了网络中数据交换和表示,使得代码,数据和表示分离,并作为数据交换的标准格式,被称为智能数据文档. 2:当我们不使用数据库来存储数 ...
- xml基础学习笔记05
Xpath快速解析 如题一样,本篇主要说说Xpath快速查找XML文档 * Xpatn.Xquery,是专门用来查询xml的语言 * 查询xml非常快 Xpatn.Xquery,是专门用来 ...
随机推荐
- java 对于url地址的实体符号的处理
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 <dependency> <g ...
- hdoj 2602(背包)
Problem D Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Sub ...
- 【HDU4010】【LCT】Query on The Trees
Problem Description We have met so many problems on the tree, so today we will have a query problem ...
- 仿小米网jQuery全屏滚动插件fullPage.js
演 示 下 载 简介 如今我们经常能见到全屏网站,尤其是国外网站.这些网站用几幅很大的图片或色块做背景,再添加一些简单的内容,显得格外的高端大气上档次.比如 iPhone 5C 的介绍页面,QQ浏 ...
- 第三篇、调优之路 Apache调优
1. 简介 在第一篇中整合了apache + tomcat ,利用了apache解析静态文件为tomcat解压.但是在测试机上发现两者性能不足,不能充分利用服务器的性能,该篇中将对apache进行性 ...
- 关于alarm函数
#include<unistd.h> #include<signal.h> void handler() { printf("Hello\n"); sign ...
- PHP 开启 ssh2
首先,为PHP安装SSH2扩展需要两个软件包, libssh2和ssh2(php pecl拓展). 两者的最新版本分别为libssh2-1.5.0.tar.gz和ssh2-0.12.tgz,下载地址分 ...
- WPF学习笔记-自定义窗口
代码部分 <Style x:Key="for_noresize_window" TargetType="{x:Type Window}"> < ...
- Comparing randomized search and grid search for hyperparameter estimation
Comparing randomized search and grid search for hyperparameter estimation Compare randomized search ...
- UIPickerView 地区解析 -- 全国省、市、区 plist 解析 -- 读取UIPickerView 当前显示内容
一个简单的plist 解析过程,借助UIPickerView 实现了手选全国的 省市区 方法, 源码中有详细注释:长句自己可以拆开看,最好的方法是,拆开,并打印,查看每一步打印的结果,结合Plist文 ...