我的afterMethod
由以下部分组成:
@AfterMethod(groups = { "Regression" })
public void afterMethod() {
// Setting driver used to false as this test case is pass
driverUsed.put("supportDriver", false);
System.out.println("Test case is pass");
}
我把驱动程序false
放在哪里
但我只想在@Test
通过时运行这个afterMethod
,而不是在@test
失败时运行。
引用TestNG的文档:
任何
@AfterMethod
方法都可以声明ITestResult
类型的参数,该参数将反映刚刚运行的测试方法的结果。
您可以使用此参数检查测试是否成功:
@AfterMethod(groups = { "Regression" })
public void afterMethod(ITestResult result) {
if (result.getStatus() == ITestResult.SUCCESS) {
// Setting driver used to false as this test case is pass
driverUsed.put("supportDriver", false);
System.out.println("Test case is pass");
}
}