如何在 TestNG 中为每个测试方法运行一个先决条件方法和一个后置条件方法?
利用 @BeforeMethod 和 @AfterMethod 注解,我们可以在 TestNG 中为每个测试方法运行一个先决条件方法和一个后置条件方法。
示例
@BeforeMethod
public void prerequisite(){
System.out.println("Run before every tests");
}
@AfterMethod
public void postcondition(){
System.out.println("Run after every tests ");
}
@Test
public void loanPay(){
System.out.println("Loan pay is successful");
}在 Java 类文件中,带有 @BeforeMethod 的 prerequisite() 方法将作为每个测试方法的先决条件执行。然后执行 loanPay(),最后带有 @AfterMethod 的 postcondition() 方法将运行。
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP