我的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
但是我只想在我的
afterMethod
通过时才运行此@Test
,而不是在@test
失败时才运行。 最佳答案
引用TestNG's documentation:
您可以使用此参数来检查测试是否成功:
@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");
}
}