@Override public int compare(Object o1, Object o2) { IInvokedMethod m1 = (IInvokedMethod) o1; IInvokedMethod m2 = (IInvokedMethod) o2; return m1.getTestMethod().getMethodName().compareTo(m2.getTestMethod().getMethodName()); } };
public static List<ITestNGMethod> invokedMethodsToMethods(Collection<IInvokedMethod> invokedMethods) { List<ITestNGMethod> result = Lists.newArrayList(); for (IInvokedMethod im : invokedMethods) { ITestNGMethod tm = im.getTestMethod(); tm.setDate(im.getDate()); result.add(tm); } return result; }
private boolean isClassAnnotatedWithReport(IInvokedMethod method) { ConstructorOrMethod consOrMethod = method.getTestMethod().getConstructorOrMethod(); Report annotation = consOrMethod.getDeclaringClass().getAnnotation(Report.class); return annotation != null; }
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { EasyMockSupport.injectMocks(method.getTestMethod().getInstance()); }
public static List<ITestNGMethod> invokedMethodsToMethods( Collection<IInvokedMethod> invokedMethods) { List<ITestNGMethod> result = Lists.newArrayList(); for (IInvokedMethod im : invokedMethods) { ITestNGMethod tm = im.getTestMethod(); tm.setDate(im.getDate()); result.add(tm); } return result; }
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { BaseTestMethod m = (BaseTestMethod) method.getTestMethod(); names.add("BeforeMethod=" + m.getSimpleName()); }
private static boolean containsInvokedMethod(Collection<IInvokedMethod> invoked, String string) { for (IInvokedMethod m : invoked) { if (m.getTestMethod().getMethodName().equals(string)) { return true; } } return false; }
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { BaseTestMethod m = (BaseTestMethod) method.getTestMethod(); names.add("AfterMethod=" + m.getSimpleName()); } }
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { String methodname = method.getTestMethod().getMethodName(); mapping.put(methodname, Arrays.asList(method.getTestMethod().getGroups())); }
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { String clazz = method.getTestMethod().getRealClass().getSimpleName() + "."; ordered.add(clazz + method.getTestMethod().getMethodName()); } }
private static void increments(Map<String, Integer> map, IInvokedMethod method) { String stringValue = method.getTestMethod().getMethodName(); Integer count = map.get(stringValue); if (count == null) { count = 0; } map.put(stringValue, count+1); } }
/** Returns the name of the executed test. */ private static String getTestName(IInvokedMethod method) { return StringUtils.substringAfterLast(method.getTestMethod().getTestClass().getName(), ".") + "#" + method.getTestMethod().getConstructorOrMethod().getName(); }
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { XmlTest xmlTest = method.getTestMethod().getXmlTest(); afterInvocation.add(xmlTest.getName()); }
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { XmlTest xmlTest = method.getTestMethod().getXmlTest(); beforeInvocation.add(xmlTest.getName()); }
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { logs.add("AfterInvocation_" + method.getTestMethod().getMethodName() + "_" + intToStatus(testResult)); }
private static String typeOfMethod(IInvokedMethod method) { ITestNGMethod tm = method.getTestMethod(); if (tm.isBeforeMethodConfiguration()) { return "before_method: "; } if (tm.isAfterMethodConfiguration()) { return "after_method: "; } return "test_method: "; }
private static Throwable getConfigFailureException(ITestContext context) { for (IInvokedMethod method : context.getSuite().getAllInvokedMethods()) { ITestNGMethod m = method.getTestMethod(); if (m.isBeforeSuiteConfiguration() && (!method.getTestResult().isSuccess())) { return method.getTestResult().getThrowable(); } } return null; }
private void log(String prefix, IInvokedMethod method, ITestResult testResult) { String msg = prefix + "_" + typeOfMethod(method); msg += method.getTestMethod().getMethodName() + parameters(testResult); if (method.isConfigurationMethod()) { configMsgs.add(msg); } else { messages.add(msg); } }
@Override public void afterInvocation(IInvokedMethod method, ITestResult testResult) { m_afterCount++; if (method.getTestMethod().isAfterSuiteConfiguration()) { suiteStatus = testResult.getStatus(); suiteThrowable = testResult.getThrowable(); } if (method.getTestMethod().isTest()) { methodStatus = testResult.getStatus(); methodThrowable = testResult.getThrowable(); } }
private static Throwable getConfigFailureException(ITestContext context) { for (IInvokedMethod method : context.getSuite().getAllInvokedMethods()) { ITestNGMethod m = method.getTestMethod(); if (m.isBeforeSuiteConfiguration() && (!method.getTestResult().isSuccess())) { return method.getTestResult().getThrowable(); } } return null; } }