TestNG执行顺序控制
1.class执行顺序控制---testng.xml之preserve-order
preserve-order:用来控制<test>里面所有<classes>的执行顺序。<test>中默认的preserve-order为true,表示<test>下所有<classes>按照顺序执行,如:

<span style="font-size:12px;">1. <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="suite1">
<test name="test" preserve-order="true">
<classes >
<
class
name="com.pack.ClassTwo">
<span style="white-space:pre;"> </span><
class
name="com.pack.ClassThree">
<span style="white-space:pre;"> </span><
class
name="com.pack.ClassOne">
</classes >
</test>
</suite></span>

执行顺序:按照ClassTwo,ClassThree,ClassOne执行
【注】 一个<class>类里面可能存在多个测试方法(被@Test注解的方法),这些方法的执行顺序不受preserve-order控制。默认测试方法的执行顺序是按照方法名的首字母升序排序执行的。
2.@test执行顺序控制
(1) 使用priority指定执行顺序(默认值为0),数值越小,越靠前执行,如:

<span style="font-size:12px;">@Test(priority = 0)
public void testMethod1() {
}
@Test(priority = 1)
public void testMethod2() {
}
@Test(priority = 2)
public void testMethod3() {
}</span>

执行顺序:按照testMethod1、testMethod2、testMethod3顺序执行
(2) 方法名称按首字母排序
因为默认执行顺序是按照方法名的首字母升序排序执行。那么,有目的地去定制方法名称,就可以让方法按照我们要求的顺序执行。如:

<span style="font-size:12px;">
@Test public void B() {
}
@Test public void A() {
}
@Test public void C() {
}</span>

执行顺序:按照A、B、C顺序执行。
(3) 在xml里面使用<include>指定需要执行的方法和顺序,如:

<span style="font-size:12px;"> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"><suite name="Preserve order test runs">
<test name="test" preserve-order="true">
<classes>
<class name="com.pack.ClassOne">
<methods>
<include name="B" />
<include name="A" />
</methods>
</class>
</classes>
</test></suite></span>

TestNG执行顺序控制的更多相关文章
- 【转】TestNG执行顺序控制
1.class执行顺序控制---testng.xml之preserve-order preserve-order:用来控制<test>里面所有<classes>的执行顺序.&l ...
- Linux:命令执行顺序控制与管道
命令执行顺序控制与管道 顺序执行 简单的顺序命令可以使用符号";"完成,如:sudo apt-get update;sudo apt-get install some-tool;s ...
- 如何解决testng执行用例失败自动重跑问题
注: 以下内容引自 http://blog.csdn.net/MenofGod/article/details/72846649 看过几个相关问题的帖子,内容类似,不过这篇解决问题的步骤和代码比较清晰 ...
- testng入门教程12 TestNG执行多线程测试
testng入门教程 TestNG执行多线程测试 testng入门教程 TestNG执行多线程测试 并行(多线程)技术在软件术语里被定义为软件.操作系统或者程序可以并行地执行另外一段程序中多个部分或者 ...
- linux学习5-命令执行顺序控制与管道
一.命令执行顺序控制 1.顺序执行命令——[:] eg:whoami:cd ~:pwd 问题:不适合存在依赖关系的命令 2.有选择的执行命令[&&].[||] [&&] ...
- testng入门教程4用TestNG执行case
使用TestNG类执行测试用例.这个类的主入口点在TestNG的框架运行测试.用户可以创建自己的TestNG的对象,并调用它以许多不同的方式: 在现有的testng.xml 合成testng.xml, ...
- testng入门教程3用TestNG执行case的顺序
本教程介绍了TestNG中执行程序的方法,这意味着该方法被称为第一和一个接着.下面是执行程序的TestNG测试API的方法的例子. 创建一个Java类文件名TestngAnnotation.java在 ...
- TestNG执行测试用例的顺序
import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.openqa.selenium.WebEle ...
- testng执行报错:org.testng.TestNGException: Cannot find class in classpath
org.testng.TestNGException: Cannot find class in classpath 解决办法:project->clean 再次执行正常运行
随机推荐
- java-we不在esclipse创建servlet之后改名不起作用的问题归纳
有时候我们不满意类名而去改名,但是改过了之后却发现不能实现它本来该实现的功能了,这是为什么呢,原因就是在2.5里面创建了servlet之后就会在web.xml里生成关于这个servlet的配置,你只是 ...
- django-缓存django-redis
https://django-redis-chs.readthedocs.io/zh_CN/latest/ 安装 django-redis 最简单的方法就是用 pip : pip install dj ...
- GlusterFS Dispersed Volume(纠错卷)总结
https://blog.csdn.net/daydayup_gzm/article/details/52748812 一.概念 Dispersed Volume是基于ErasureCodes(纠错码 ...
- 简述Python的深浅拷贝以及应用场景?
浅拷贝:copy.copy 深拷贝:copy.deepcopy 浅拷贝指仅仅拷贝数据集合的第一层数据,深拷贝指拷贝数据集合的所有层 主要应用在字符串,数字的 ...
- LeetCode 457. Circular Array Loop
原题链接在这里:https://leetcode.com/problems/circular-array-loop/ 题目: You are given a circular array nums o ...
- Greenplum常用的gp_toolkit & pg_catalog监控语句
gp_toolkit 说明 Greenplum数据库提供了一个名为gp_tooikit的管理schema,该schema下有关于查询系统目录,日志文件, 用户创建(databases,schema,t ...
- Omnibus 安装
使用gem gem install omnibus 说明 可能需要配置gem source ,通过 gem source list 可以进行检查 参考如下: gem source -r https ...
- 函数(定义、参数、return、变量、作用域、预解析)
一.函数定义 1.方式一 function 函数名(参数){ 函数体 }——————函数声明的方法 function fn(a){ console.log(a); }: 2.方式二 ...
- 完美兼容IE10以下所有版本
IE一直是个恶心东西 各种不支持 现在发现了个好东西可以兼容ie10以下所有浏览器 <!--[if lte IE 9]><script>window.location.href ...
- Noip2019暑期训练2
题目名称 骑士遍历 和谐俱乐部 农场派对 对称二叉树 存盘文件名 knight Beautiful party tree 输入文件名 knight.in Beautiful.in party.in ...