org.testng.IInvokedMethod Java Examples
The following examples show how to use
org.testng.IInvokedMethod.
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: CacheValidationListener.java From caffeine with Apache License 2.0 | 6 votes |
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { try { if (testResult.isSuccess()) { validate(testResult); } else { if (!detailedParams.get()) { detailedParams.set(true); } testResult.setThrowable(new AssertionError(getTestName(method), testResult.getThrowable())); } } catch (Throwable caught) { testResult.setStatus(ITestResult.FAILURE); testResult.setThrowable(new AssertionError(getTestName(method), caught)); } finally { cleanUp(testResult); } }
Example #2
Source File: GatekeeperBehaviour.java From cloudbreak with Apache License 2.0 | 6 votes |
@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 #3
Source File: AppiumParallelTestListener.java From AppiumTestDistribution with GNU General Public License v3.0 | 6 votes |
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { JSONObject json = new JSONObject(); json.put("id", AppiumDeviceManager.getAppiumDevice().getDevice().getUdid()); json.put("version", new AppiumDeviceManager().getDeviceVersion()); json.put("platform", AppiumDeviceManager.getMobilePlatform()); json.put("model", new AppiumDeviceManager().getDeviceModel()); try { if (testResult.getStatus() == ITestResult.SUCCESS || testResult.getStatus() == ITestResult.FAILURE) { HashMap<String, String> logs = testLogger.endLogging(testResult, AppiumDeviceManager.getAppiumDevice().getDevice().getDeviceModel()); if (atdHost.isPresent() && atdPort.isPresent()) { String postTestResults = "http://" + atdHost.get() + ":" + atdPort.get() + "/testresults"; sendResultsToAtdService(testResult, "Completed", postTestResults, logs); } } if (method.isTestMethod()) { appiumDriverManager.stopAppiumDriver(); } } catch (Exception e) { e.printStackTrace(); } SessionContext.remove(Thread.currentThread().getId()); queueAfterInvocationListener(method, testResult, iTestNGListeners); }
Example #4
Source File: AllureTestNg.java From allure-java with Apache License 2.0 | 6 votes |
@Override public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) { final ITestNGMethod testMethod = method.getTestMethod(); if (isSupportedConfigurationFixture(testMethod)) { final String executableUuid = currentExecutable.get(); currentExecutable.remove(); if (testResult.isSuccess()) { getLifecycle().updateFixture(executableUuid, result -> result.setStatus(Status.PASSED)); } else { getLifecycle().updateFixture(executableUuid, result -> result .setStatus(getStatus(testResult.getThrowable())) .setStatusDetails(getStatusDetails(testResult.getThrowable()).orElse(null))); } getLifecycle().stopFixture(executableUuid); if (testMethod.isBeforeMethodConfiguration() || testMethod.isAfterMethodConfiguration()) { final String containerUuid = currentTestContainer.get(); validateContainerExists(getQualifiedName(testMethod), containerUuid); currentTestContainer.remove(); getLifecycle().stopTestContainer(containerUuid); getLifecycle().writeTestContainer(containerUuid); } } }
Example #5
Source File: AppiumParallelMethodTestListener.java From AppiumTestDistribution with GNU General Public License v3.0 | 6 votes |
@Override public void beforeInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) { allocateDeviceAndStartDriver(iTestResult); if (!isCloudExecution()) { currentMethods.set(iInvokedMethod.getTestMethod()); SkipIf annotation = iInvokedMethod.getTestMethod().getConstructorOrMethod().getMethod() .getAnnotation(SkipIf.class); if (annotation != null && AppiumDriverManager.getDriver().getPlatformName() .equalsIgnoreCase(annotation.platform())) { if (atdHost.isPresent() && atdPort.isPresent()) { HashMap<String, String> logs = new HashMap<>(); String url = "http://" + atdHost.get() + ":" + atdPort.get() + "/testresults"; sendResultsToAtdService(iTestResult, "Completed", url, logs); } throw new SkipException("Skipped because property was set to :::" + annotation.platform()); } } new TestExecutionContext(iInvokedMethod.getTestMethod().getMethodName()); queueBeforeInvocationListeners(iInvokedMethod, iTestResult, listeners); }
Example #6
Source File: ReportManagerHook.java From difido-reports with Apache License 2.0 | 6 votes |
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { if (method.getTestMethod().isBeforeClassConfiguration() | method.getTestMethod().isBeforeGroupsConfiguration() | method.getTestMethod().isBeforeMethodConfiguration() | method.getTestMethod().isBeforeSuiteConfiguration() | method.getTestMethod().isBeforeTestConfiguration()) { beforeSetup(method, testResult); } else if (method.getTestMethod().isAfterClassConfiguration() | method.getTestMethod().isAfterGroupsConfiguration() | method.getTestMethod().isAfterMethodConfiguration() | method.getTestMethod().isAfterSuiteConfiguration() | method.getTestMethod().isAfterTestConfiguration()) { beforeTeardown(method, testResult); } }
Example #7
Source File: LogTestDurationListener.java From presto with Apache License 2.0 | 5 votes |
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { if (!enabled) { return; } String name = getName(method); Duration duration = endTest(name); if (duration.compareTo(SINGLE_TEST_LOGGING_THRESHOLD) > 0) { LOG.info("Test %s took %s", name, duration); } }
Example #8
Source File: LogTestDurationListener.java From presto with Apache License 2.0 | 5 votes |
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { if (!enabled) { return; } beginTest(getName(method)); }
Example #9
Source File: InvokedMethodNameListener.java From test-data-supplier with Apache License 2.0 | 5 votes |
@Override public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) { if (method.isTestMethod()) { final String name = getName(testResult); Match(testResult.getStatus()).of( Case($(FAILURE), () -> failedMethodNames.add(name)), Case($(SKIP), () -> skippedMethodNames.add(name)), Case($(SUCCESS), () -> succeedMethodNames.add(name)), Case($(), () -> { throw new AssertionError("Unexpected value: " + testResult.getStatus()); }) ); } }
Example #10
Source File: InvokedMethodNameListener.java From test-data-supplier with Apache License 2.0 | 5 votes |
@Override public void beforeInvocation(final IInvokedMethod method, final ITestResult testResult) { if (method.isTestMethod()) { final String rawMethodName = method.getTestMethod().getMethodName(); final long currentThreadId = Thread.currentThread().getId(); threads.putIfAbsent(rawMethodName, new CopyOnWriteArrayList<>()); threads.computeIfPresent(rawMethodName, (s, l) -> StreamEx.of(l).append(currentThreadId).distinct().toList()); invokedMethodNames.add(getName(testResult)); } }
Example #11
Source File: EverrestJetty.java From everrest with Eclipse Public License 2.0 | 5 votes |
/** * @see org.testng.IInvokedMethodListener#beforeInvocation(org.testng.IInvokedMethod, * org.testng.ITestResult) */ @Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { if (httpServer != null && hasEverrestJettyListener(method.getTestMethod().getInstance().getClass())) { httpServer.resetFactories(); httpServer.resetFilter(); initRestResource(method.getTestMethod()); } }
Example #12
Source File: AllureTestNg.java From allure-java with Apache License 2.0 | 5 votes |
@Override public void beforeInvocation(final IInvokedMethod method, final ITestResult testResult) { final ITestNGMethod testMethod = method.getTestMethod(); final ITestContext context = testResult.getTestContext(); if (isSupportedConfigurationFixture(testMethod)) { ifSuiteFixtureStarted(context.getSuite(), testMethod); ifTestFixtureStarted(context, testMethod); ifClassFixtureStarted(testMethod); ifMethodFixtureStarted(testMethod); } }
Example #13
Source File: ArkTestNGInvokedMethodListener.java From sofa-ark with Apache License 2.0 | 5 votes |
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { Class testClass = method.getTestMethod().getTestClass().getRealClass(); if (isTestOnArk(testClass)) { ClassLoaderUtils.pushContextClassLoader(DelegateArkContainer.getTestClassLoader()); } }
Example #14
Source File: PowerEmailableReporter.java From WebAndAppUITesting with GNU General Public License v3.0 | 5 votes |
/** * Get All tests id by class + method + parameters hash code. * * @param context * @param suite */ private void getAllTestIds(ITestContext context, ISuite suite) { IResultMap passTests = context.getPassedTests(); IResultMap failTests = context.getFailedTests(); List<IInvokedMethod> invokedMethods = suite.getAllInvokedMethods(); for (IInvokedMethod im : invokedMethods) { if (passTests.getAllMethods().contains(im.getTestMethod()) || failTests.getAllMethods().contains(im.getTestMethod())) { int testId = getId(im.getTestResult()); // m_out.println("ALLtestid=" + testId); allRunTestIds.add(testId); } } }
Example #15
Source File: DriverListener.java From Selenium-Foundation with Apache License 2.0 | 5 votes |
/** * Perform post-invocation processing: * <ul> * <li>If indicated, close the driver that was acquired for this method.</li> * </ul> * * @param invokedMethod an object representing the method that's just been invoked * @param testResult test result object for the method that's just been invoked */ @Override public void afterInvocation(final IInvokedMethod invokedMethod, final ITestResult testResult) { // ensure current test result is set Reporter.setCurrentTestResult(testResult); Object obj = testResult.getInstance(); Method method = invokedMethod.getTestMethod().getConstructorOrMethod().getMethod(); DriverManager.afterInvocation(obj, method); }
Example #16
Source File: TestMethodListener.java From oxd with Apache License 2.0 | 5 votes |
@Override public void beforeInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) { Method method = iTestResult.getMethod().getConstructorOrMethod().getMethod(); if (method == null) { return; } if (method.isAnnotationPresent(ProtectionAccessTokenRequired.class)) { if (!Tester.isTokenProtectionEnabled()) { iTestResult.setStatus(ITestResult.SKIP); throw new SkipException("Skipping the test as protection access token is not enabled. Ignore the exception."); } } }
Example #17
Source File: QAFTestNGListener.java From qaf with MIT License | 5 votes |
public void afterInvocation(final IInvokedMethod method, final ITestResult tr, final ITestContext context) { logger.debug("afterInvocation: " + method.getTestMethod().getMethodName() + " - " + method.getTestMethod().getConstructorOrMethod() .getDeclaringClass().getName() + " is test:" + method.isTestMethod()); // if (method.isTestMethod()) { processResult(tr, context); // } logger.debug("afterInvocation: Done"); }
Example #18
Source File: ApplicationComposerListener.java From tomee with Apache License 2.0 | 5 votes |
@Override public void beforeInvocation(final IInvokedMethod method, final ITestResult testResult) { delegate = new ApplicationComposers(method.getTestMethod().getRealClass()); try { delegate.before(testResult.getInstance()); } catch (final Exception e) { throw new OpenEJBRuntimeException(e); } }
Example #19
Source File: SeleniumTestHandler.java From che with Eclipse Public License 2.0 | 5 votes |
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { Object invokingTestInstance = method.getTestMethod().getInstance(); if (runningTests.containsValue(invokingTestInstance)) { return; } long currentThreadId = Thread.currentThread().getId(); if (isNewTestInProgress(invokingTestInstance)) { Object previousTestInstance = runningTests.remove(currentThreadId); preDestroy(previousTestInstance); testsWithFailure.remove(previousTestInstance.getClass().getName()); } String testName = invokingTestInstance.getClass().getName(); try { LOG.info("Dependencies injection in {}", testName); injectDependencies(testResult.getTestContext(), invokingTestInstance); } catch (Exception e) { String errorMessage = "Failed to inject fields in " + testName; LOG.error(errorMessage, e); throw new TestException(errorMessage, e); } finally { runningTests.put(currentThreadId, invokingTestInstance); } }
Example #20
Source File: ReportManager.java From difido-reports with Apache License 2.0 | 5 votes |
@Override public void afterTeardown(IInvokedMethod method, ITestResult testResult) { for (Reporter reporter : reporters) { reporter.afterTeardown(method, testResult); } }
Example #21
Source File: AppiumParallelTestListener.java From AppiumTestDistribution with GNU General Public License v3.0 | 5 votes |
@Override public void beforeInvocation(IInvokedMethod iInvokedMethod, ITestResult testResult) { currentMethods.set(iInvokedMethod.getTestMethod()); SkipIf annotation = iInvokedMethod.getTestMethod().getConstructorOrMethod().getMethod() .getAnnotation(SkipIf.class); if (annotation != null && AppiumDriverManager.getDriver().getPlatformName() .equalsIgnoreCase(annotation.platform())) { throw new SkipException("Skipped because property was set to :::" + annotation.platform()); } new TestExecutionContext(iInvokedMethod.getTestMethod().getMethodName()); queueBeforeInvocationListeners(iInvokedMethod, testResult, iTestNGListeners); }
Example #22
Source File: MockitoAfterTestNGMethod.java From mockito-cookbook with Apache License 2.0 | 5 votes |
public void applyFor(IInvokedMethod method, ITestResult testResult) { Mockito.validateMockitoUsage(); if (method.isTestMethod()) { resetMocks(testResult.getInstance()); } }
Example #23
Source File: MockitoAfterTestNGMethod.java From astor with GNU General Public License v2.0 | 5 votes |
public void applyFor(IInvokedMethod method, ITestResult testResult) { Mockito.validateMockitoUsage(); if (method.isTestMethod()) { resetMocks(testResult.getInstance()); } }
Example #24
Source File: ApplicationComposerListener.java From tomee with Apache License 2.0 | 5 votes |
@Override public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) { try { delegate.after(); } catch (final Exception e) { throw new OpenEJBRuntimeException(e); } }
Example #25
Source File: ConditionsListener.java From stevia with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) { int failed = findFailed(context); if (failed > 0) { LOG.error("Preconditions execution will not proceed. {} Configurations have failed",failed); return; } Method rmethod = method.getTestMethod().getConstructorOrMethod().getMethod(); Object proxy = proxifyObject(method); if (rmethod.getAnnotation(Test.class) != null) { if (rmethod.getAnnotation(Preconditions.class) != null) { LOG.warn("Method or Class of {} wants preconditions to be checked", rmethod.getName()); AnnotationsHelper p = SteviaContext.getSpringContext().getBean(AnnotationsHelper.class); try { LOG.debug("Mask and Execute Preconditions of method {} ",rmethod.getName()); p.maskAndExecPreconditions(rmethod, proxy); LOG.debug("Mask and Execute Preconditions of method {} DONE",rmethod.getName()); } catch (Throwable e) { Throwable realException = findExceptionWithMessage(e); LOG.error("Detected exception in preconditions execution, message = "+realException.getMessage(),e); if (realException instanceof RuntimeException ) { throw ((RuntimeException)realException); } else { throw new IllegalStateException(realException.getMessage(),realException); } } } } }
Example #26
Source File: CustomeListener.java From AppiumTestDistribution with GNU General Public License v3.0 | 5 votes |
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { String msg = String.format("%s.afterInvocation() was invoked", getClass().getName()); System.out.println("After DeviceId" + AppiumDeviceManager.getAppiumDevice().getDevice().getUdid()); System.err.println(msg); }
Example #27
Source File: CustomeListener.java From AppiumTestDistribution with GNU General Public License v3.0 | 5 votes |
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { String msg = String.format("%s.beforeInvocation() was invoked", getClass().getName()); System.out.println("Before DeviceId" + AppiumDeviceManager.getAppiumDevice().getDevice().getUdid()); System.err.println(msg); }
Example #28
Source File: WebTesterTestNGListener.java From webtester-core with Apache License 2.0 | 5 votes |
@Override public void afterInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) { Method method = iInvokedMethod.getTestMethod().getConstructorOrMethod().getMethod(); if (method.isAnnotationPresent(AfterMethod.class) || method.isAnnotationPresent(Test.class)) { executeAfterTestForAllBrowsers(); } }
Example #29
Source File: ControllerMaskingListener.java From stevia with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) { if (masked) { AnnotationsHelper p = SteviaContext.getSpringContext().getBean(AnnotationsHelper.class); try { p.controllerUnmask(); masked = false; } catch (Throwable e) { throw new IllegalStateException("failed to replace masked controller",e); } } }
Example #30
Source File: ReportManager.java From difido-reports with Apache License 2.0 | 5 votes |
@Override public void beforeSetup(IInvokedMethod method, ITestResult testResult) { for (Reporter reporter : reporters) { reporter.beforeSetup(method, testResult); } }