public static void dumpInvokedMethodsInfoToConsole(Collection<IInvokedMethod> iInvokedMethods, int currentVerbosity) { if (currentVerbosity < 3) { return; } System.out.println("===== Invoked methods"); for (IInvokedMethod im : iInvokedMethods) { if (im.isTestMethod()) { System.out.print(" "); } else if (im.isConfigurationMethod()) { System.out.print(" "); } else { continue; } System.out.println("" + im); } System.out.println("====="); }
public static void dumpInvokedMethodsInfoToConsole( Collection<IInvokedMethod> iInvokedMethods, int currentVerbosity) { if (currentVerbosity < 3) { return; } System.out.println("===== Invoked methods"); for (IInvokedMethod im : iInvokedMethods) { if (im.isTestMethod()) { System.out.print(" "); } else if (im.isConfigurationMethod()) { System.out.print(" "); } else { continue; } System.out.println("" + im); } System.out.println("====="); }
@Override public void beforeInvocation(final IInvokedMethod method, final ITestResult testResult) { if (!method.isTestMethod()) { return; } synchronized (this) { if (hasFailures) { throw new SkipException("Skipping this test"); } } }
@Override public void afterInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) { if (iInvokedMethod.isTestMethod()) { String attribute = Github1600Analyzer.NO; if (iTestResult.getStatus() == ITestResult.SUCCESS) { iTestResult.setStatus(ITestResult.FAILURE); attribute = Github1600Analyzer.YES; } iTestResult.setAttribute(Github1600Analyzer.RETRY, attribute); } }
@Override public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) { if (!method.isTestMethod()) { return; } if (testResult.getStatus() == ITestResult.FAILURE) { // Don't skip other tests with the current test method is flaky final boolean isFlakyTest = method.getTestMethod().getRetryAnalyzer() != null && method.getTestMethod().getRetryAnalyzer() instanceof FlakyRetryAnalyzer; if (!isFlakyTest) { synchronized (this) { logger.warn("!!! Test failure, all other tests will be skipped: {} !!!", testResult); hasFailures = true; } } } }
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { String methodName = method.getTestMethod().getMethodName(); if (method.isTestMethod()) { testMethods.add(methodName); } if (method.isConfigurationMethod()) { configurationMethods.add(methodName); } if (method.getTestMethod().isTest()) { testMethodsFromTM.add(methodName); } if (method.getTestMethod().isBeforeMethodConfiguration() || method.getTestMethod().isAfterMethodConfiguration() || method.getTestMethod().isBeforeTestConfiguration() || method.getTestMethod().isAfterTestConfiguration() || method.getTestMethod().isBeforeClassConfiguration() || method.getTestMethod().isAfterClassConfiguration() || method.getTestMethod().isBeforeSuiteConfiguration() || method.getTestMethod().isAfterSuiteConfiguration()) { configurationMethodsFromTM.add(methodName); } } }
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { if (method.isTestMethod()) { TestCoverage.INSTANCE.setCurrentTestMethod(null); } } }
public void afterInvocation(IInvokedMethod method, ITestResult testResult) { if (!method.isTestMethod()) return; ITestNGMethod testMethod = method.getTestMethod(); IClass clazz = testMethod.getTestClass(); double elapsed = (System.currentTimeMillis() - START_TIMES.remove(testMethod)) / 1000.0; if (elapsed > 1) LoggerFactory.getLogger("AFTER").info("{}#{} Ran for {} seconds", clazz.getRealClass().getName(), testMethod.getMethodName(), elapsed); } }
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { if (!method.isTestMethod()) return; ITestNGMethod testMethod = method.getTestMethod(); IClass clazz = testMethod.getTestClass(); START_TIMES.put(testMethod, System.currentTimeMillis()); LoggerFactory.getLogger("BEFORE").info("{}#{}", clazz.getRealClass().getName(), testMethod.getMethodName()); }
private boolean isValidBeforeCondition(IInvokedMethod method) { if (method.isTestMethod()) { return true; } return method.getTestMethod().isBeforeClassConfiguration(); }
/** * Validate Mockito usage and reset mocks. * * @param testMethod the invoked test method. * @param testResult metadata about the class under test. */ public void applyFor(IInvokedMethod testMethod, ITestResult testResult) { Mockito.validateMockitoUsage(); if (testMethod.isTestMethod()) { Object testInstance = testResult.getInstance(); Mockito.reset(instanceMocksOf(testInstance).toArray()); } }
@Override public void afterInvocation(IInvokedMethod method, ITestResult result) { if (method.isTestMethod()) { List<String> fails = getFails(); if (!fails.isEmpty()) { fails.forEach(logger::error); result.setStatus(FAILURE); } logger.info("=== Test '%s' %s ===", testName, getTestResult(result)); } }
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { if (method.isTestMethod()) { logger.info("> Running [{}.{}]", method.getTestMethod().getTestClass().getRealClass().getSimpleName(), method.getTestMethod().getMethodName()); } }
@Override public void beforeInvocation(final IInvokedMethod method, final ITestResult testResult) { if (!method.isTestMethod()) { return; } synchronized (this) { if (hasFailures) { throw new SkipException("Skipping this test"); } } }
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { if (method.isTestMethod() && testResult.getStatus() != ITestResult.SUCCESS) { State.caughtExceptionAfter(testResult.getThrowable()); } }
@Override public void afterInvocation(IInvokedMethod method, ITestResult result) { if (method.isTestMethod()) { List<String> fails = getFails(); if (!fails.isEmpty()) { for (String fail : fails) logger.error(fail); result.setStatus(FAILURE); } logger.info("=== Test '%s' %s ===", testName, getTestResult(result)); } }
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { if (method.isTestMethod()) { Method testMethod = method.getTestMethod().getConstructorOrMethod().getMethod(); TestCoverage.INSTANCE.setCurrentTestMethod(testMethod); } }
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) { TestLogging.setCurrentTestResult(testResult); // issue #94: add ability to request thread context from a method annotated with @BeforeMethod // for each beforemethod, store the current context so that it can be edited by the configuration method if (method.isConfigurationMethod()) { configureThreadContextBeforeInvoke(method, testResult, context); } if (method.isTestMethod()) { executeBeforeTestMethod(method, testResult, context); } }
@Override public void beforeInvocation(final IInvokedMethod method, final ITestResult testResult) { if (method.isTestMethod()) { UnitSupport.getInstance().beforeScript(method.getTestMethod().getMethodName()); } }
@Override public void afterInvocation(final IInvokedMethod method, final ITestResult testResult) { if (method.isTestMethod()) { UnitSupport.getInstance().afterScript(method.getTestMethod().getMethodName(), testResult.isSuccess(), testResult.getThrowable()); } }