java - java中testng注解的使用方法

标签 java annotations testng selendroid

我的代码

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/

相关文章:

java - 使用 CXF 对 JAX-RS 子资源进行 Bean 验证

java - Eclipse Neon 快速辅助自动添加@NonNull

java - Appium/ Selenium : testNG parallel execution not working

java - TestNG with IntelliJ IDEA : How to use the testng. IntelliJ IDEA 9 中的 xml 文件

java - 在 TestNG xml 文件中,如何在 beanshell 中调用另一个 java 方法?

java - 并行测试中的控制台输出显示在不同的测试树中,而不是在

java - 查询必须以 SELECT 或 FROM : delete [delete 开头

java - XML Pull Parser 和 SAX Parser 有什么区别

java - Ionic with Tomcat - 成功登录,但没有注入(inject)主体

java - 创建 JFreeChart 后进行绘图