下面列出了org.testng.ITestNGMethod#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
if (!isThisSuiteListener(testResult)) {
return;
}
if (method.isTestMethod()) {
ITestNGMethod thisMethod = method.getTestMethod();
ITestNGMethod[] allTestMethods = testResult.getTestContext().getAllTestMethods();
ITestNGMethod firstMethod = allTestMethods[0];
if (thisMethod.equals(firstMethod)) {
Map<String, ISuiteResult> results = testResult.getTestContext().getSuite().getResults();
if (hasFailedGatekeeperTest(results)) {
throw new GatekeeperException(SKIP_MESSAGE);
}
} else {
IResultMap skippedTests = testResult.getTestContext().getSkippedTests();
if (anyTestsSkippedBecauseOfGatekeeper(skippedTests)) {
throw new GatekeeperException(SKIP_MESSAGE);
}
}
}
}
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
if (!isThisSuiteListener(testResult)) {
return;
}
if (method.isTestMethod()) {
ITestNGMethod thisMethod = method.getTestMethod();
ITestNGMethod[] allTestMethods = testResult.getTestContext().getAllTestMethods();
ITestNGMethod firstMethod = allTestMethods[0];
ITestNGMethod lastMethod = allTestMethods[allTestMethods.length - 1];
if (!thisMethod.equals(firstMethod) && !thisMethod.equals(lastMethod)) {
IResultMap success = testResult.getTestContext().getPassedTests();
if (!success.getAllMethods().contains(firstMethod)) {
throw new SkipException("Skipped because first method was not succcessfull");
}
}
}
}