WEB端UI自动化测试(三)testNG监听和注释

一、eclipse中testNG安装

1、eclipse-->help-->安装新软件

 

 2.点击add,name随便写,location写 http://beust.com/eclipse/,选择软件之后next完成安装

 

 二、testNG注释

@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.

 

三、TestNG Suite 运行出现中文乱码如何解决

 
场景: 用TestNG框架运行测试类,results of running suite中文乱码
解决方案:
1、修改eclipse.ini 文件,文件末尾添加: -Dfile.encoding=UTF-8,保存之后最后重新启动eclipse,以确保eclipse.ini 修改生效。
2、右键: Run As>Run configurations>other>utf-8
       
posted @ 2019-10-17 19:44  归藏  阅读(287)  评论(0)    收藏  举报