Abh*_*mas 5 java testng selenium
我的成员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");
}
Run Code Online (Sandbox Code Playgroud)
我把司机放在哪里 false
但是我想afterMethod只在我@Test通过时才运行它,而不是在@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");
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
387 次 |
| 最近记录: |