我的代码
public class Test{
@BeforeTest
public void create_user throws Exception (){
}
@Test
public void user_actions throws Exception (){
}
@AfterTest
public void delete_user throws Exception(){
}
}
上面是我的测试课。如果我在 create_user()
中遇到任何错误,目前它会抛出 Exception
并跑出测试用例。
但我需要 delete_user()
应该被执行,而不管 create_user()
或 user_actions()
最佳答案
尝试@AfterTest(alwaysRun = true)
。
来自TestNG doc :
For after methods (afterSuite, afterClass, ...): If set to true, this configuration method will be run even if one or more methods invoked previously failed or was skipped.
关于java - java中testng注解的使用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30101325/