告诉你TestNG annotations注释都是什么时候运行的
来源:互联网 发布:如何检查网络是否丢包 编辑:程序博客网 时间:2024/05/14 04:58
package com.testng;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class testngannotationsdemo {
@Test(groups={"A组"})
public void Case1(){
System.out.println("Test:Case1被执行了!!");
}
@Test(groups={"A组"})
public void Case2(){
System.out.println("Test:Case2被执行了!!");
}
@Test
public void Case3(){
System.out.println("Test:Case3被执行了!!");
}
@BeforeMethod
public void beforemethod(){
System.out.println("BeforeMethod:在每个测试(@Test)运行之前执行");
}
@AfterMethod
public void aftermethod(){
System.out.println("AfterMethod:在每个测试(@Test)结束后执行");
}
@BeforeClass
public void BeforeClass(){
System.out.println("BeforeClass:在执行第一个测试前执行");
}
@AfterClass
public void AfterClass(){
System.out.println("AfterClass:在最后一个测试执行结束后执行");
}
@BeforeTest
public void beforetest(){
System.out.println("BeforeTest:在测试类中的测试开始执行前执行");
}
@AfterTest
public void aftertest(){
System.out.println("AfterTest:在测试类中的测试结束后执行");
}
@BeforeSuite
public void beforesuite(){
System.out.println("BeforeSuite:在执行测试集合前执行");
}
@AfterSuite
public void aftersuite(){
System.out.println("AferSuite:在执行测试集合前执行");
}
@BeforeGroups(groups={"A组"})
public void beforegroups(){
System.out.println("BeforeGroups:在分组(A组)用例任意一个用例运行前执行");
}
@AfterGroups(groups={"A组"})
public void aftergroups(){
System.out.println("AfterGroups:在分组(A组)所有用例运行结束后执行");
}
}
如下执行结果可分析出 TestNG不同注释在何时执行:
/private/var/folders/c1/wz0lthxd3n9693l0p1t7yw0h0000gn/T/testng-eclipse-1188532939/testng-customsuite.xml
BeforeSuite:在执行测试集合前执行
BeforeTest:在测试类中的测试开始执行前执行
BeforeClass:在执行第一个测试前执行
BeforeGroups:在分组(A组)用例任意一个用例运行前执行
BeforeMethod:在每个测试(@Test)运行之前执行
Test:Case1被执行了!!
AfterMethod:在每个测试(@Test)结束后执行
BeforeMethod:在每个测试(@Test)运行之前执行
Test:Case2被执行了!!
AfterMethod:在每个测试(@Test)结束后执行
AfterGroups:在分组(A组)所有用例运行结束后执行
BeforeMethod:在每个测试(@Test)运行之前执行
Test:Case3被执行了!!
AfterMethod:在每个测试(@Test)结束后执行
AfterClass:在最后一个测试执行结束后执行
AfterTest:在测试类中的测试结束后执行
PASSED: Case1
PASSED: Case2
PASSED: Case3
===============================================
Default test
Tests run: 3, Failures: 0, Skips: 0
===============================================
AferSuite:在执行测试集合前执行
===============================================
Default suite
Total tests run: 3, Failures: 0, Skips: 0
===============================================
- 告诉你TestNG annotations注释都是什么时候运行的
- testNG注释运行顺序
- 我得告诉你这些都是真的
- TestNG-TestNG annotations
- TestNG的注释
- c++编程里面endl与\n的区别,告诉你什么时候用二者最适合
- TestNG Annotations示例
- TestNG Annotations示例
- 告诉你C盘里的每个文件夹都是干什么用的!
- 告诉你C盘里的每个文件夹都是干什么用的.......很实用....
- 应用解决告诉你什么时候该用ajax
- 应用解决告诉你什么时候该用ajax
- Nullability Annotations 为空性的注释
- Selenium-java-TestNg-的运行
- 使用TestNG:基于注释的单元测试框架
- 告诉你C盘里的每个文件夹都是干嘛的,哪个可以删除,哪些不能碰
- 告诉你Windows下如何运行Linux
- TestNG 五 运行TestNG
- TCP SYN洪泛攻击的原理及防御方法
- Nim(POJ_2975)
- Struts2 S2 – 032远程代码执行漏洞分析报告
- 1004. 成绩排名 (20)
- 第七章数据压缩技术
- 告诉你TestNG annotations注释都是什么时候运行的
- hdu2795 Billboard(单点更新)
- c/c++常用宏、预编译指令
- 等价类
- JQuery EasyUI datagrid 复杂表头处理
- LeetCode 341. Flatten Nested List Iterator(嵌套列表迭代器)
- Linux内核分析总结
- coursera 机器学习课程笔记(一)——回归问题
- 设计模式(十)观察者模式