TestNG 基本注解@BeforeMethod、@AfterMethod 和@BeforeClass、@AfterClass 的区别以及实际问题的解决

 区别:

@BeforeClass:在类运行之前执行
@AfterClass:在类运行之后执行

@BeforeMethod:在每个@Test方法执行前执行
@AfterMethod:在每个@Test方法执行后执行

实际问题解析:
场景:自动化测试脚本用例执行失败,再次进行执行浏览器无法退出以及无法打开浏览器,以至于浏览器卡住,使用注解@BeforeClass。

解决方法:使用@BeforeMethod即可

 




原文地址:https://www.cnblogs.com/zuozuo320/p/14185052.html