Java Code Examples for org.testng.ITestNGMethod#equals()

The following examples show how to use org.testng.ITestNGMethod#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GatekeeperBehaviour.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@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);
            }
        }
    }
}
 
Example 2
Source File: FirstLastTestExecutionBehaviour.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@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");
            }
        }
    }
}