@Override public int compare(ITestResult o1, ITestResult o2) { int result = o1.getTestClass().getName() .compareTo(o2.getTestClass().getName()); if (result == 0) { result = o1.getMethod().getMethodName() .compareTo(o2.getMethod().getMethodName()); } return result; } };
private void logResult(String status, ITestResult tr, String stackTrace) { logResult(status, tr.getName(), tr.getMethod().getDescription(), stackTrace, tr.getParameters(), tr.getMethod().getConstructorOrMethod().getParameterTypes()); }
/** * @return the test results that apply to one of the instances of the testMethod. */ private Set<ITestResult> keepSameInstances(ITestNGMethod method, Set<ITestResult> results) { Set<ITestResult> result = Sets.newHashSet(); for (ITestResult r : results) { Object o = method.getInstance(); // Keep this instance if 1) It's on a different class or 2) It's on the same class // and on the same instance Object instance = r.getInstance() != null ? r.getInstance() : r.getMethod().getInstance(); if (r.getTestClass() != method.getTestClass() || instance == o) result.add(r); } return result; }
/** * * A helper method that checks to see if a method is a configuration method or not. * @param method - A {@link ITestNGMethod} object which needs to be checked. * @param includeGroupConfigs - <code>true</code> if before/after group configuration annotations are also to * be taken into consideration. * @return - <code>true</code> if the method is a configuration method and false if its a test method. */ private static boolean isConfigurationMethod(ITestNGMethod method, boolean includeGroupConfigs) { boolean flag = method.isBeforeMethodConfiguration() || method.isAfterMethodConfiguration() || method.isBeforeTestConfiguration() || method.isAfterTestConfiguration() || method.isBeforeClassConfiguration() || method.isAfterClassConfiguration() || method.isBeforeSuiteConfiguration() || method.isAfterSuiteConfiguration(); if (includeGroupConfigs) { flag = flag || method.isBeforeGroupsConfiguration() || method.isAfterGroupsConfiguration(); } return flag; }
private void addMapping(SetMultiMap<Class<?>, ITestNGMethod> mapping, Collection<ITestNGMethod> methods) { for (ITestNGMethod method : methods) { if (! method.getEnabled()) { mapping.put(method.getRealClass(), method); } } } }
public static MethodParameters newInstance(Map<String, String> params, ITestNGMethod testNGMethod, ITestContext context) { Map<String, String> methodParams = testNGMethod.findMethodParameters(context.getCurrentXmlTest()); Object[] pv = null; ITestResult tr = null; Method method = testNGMethod.getConstructorOrMethod().getMethod(); return new MethodParameters(params, methodParams, pv, method, context, tr); }
ITestNGMethod method = tr.getMethod(); String name = method.getMethodName(); pw.append("<td title='").append(tr.getTestClass().getName()).append(".") .append(name) .append("()'>") String testClass = tr.getTestClass().getName(); if (testClass != null) { pw.append("<br>").append("Test class: ").append(testClass); if (! Utils.isStringEmpty(method.getDescription())) { pw.append("<br>").append("Test method: ").append(method.getDescription());
private static String prettyMsg(ITestResult result) { return "Test method : " + result.getTestClass().getRealClass().getName() + "." + result.getMethod().getMethodName() + "()" + ", Parameters : " + Arrays.toString(result.getParameters()); }
private Properties getTestResultAttributes(ITestResult testResult) { Properties attributes = new Properties(); if (!testResult.getMethod().isTest()) { attributes.setProperty(XMLReporterConfig.ATTR_IS_CONFIG, "true"); attributes.setProperty(XMLReporterConfig.ATTR_NAME, testResult.getMethod().getMethodName()); String testInstanceName = testResult.getTestName(); if (null != testInstanceName) { attributes.setProperty(XMLReporterConfig.ATTR_TEST_INSTANCE_NAME, testInstanceName); String description = testResult.getMethod().getDescription(); if (!Utils.isStringEmpty(description)) { attributes.setProperty(XMLReporterConfig.ATTR_DESC, description); String groupNamesStr = Utils.arrayToString(testResult.getMethod().getGroups()); if (!Utils.isStringEmpty(groupNamesStr)) { attributes.setProperty(XMLReporterConfig.ATTR_GROUPS, groupNamesStr); String dependsOnStr = Utils.arrayToString(testResult.getMethod().getMethodsDependedUpon()); if (!Utils.isStringEmpty(dependsOnStr)) { attributes.setProperty(XMLReporterConfig.ATTR_DEPENDS_ON_METHODS, dependsOnStr); String dependsOnStr = Utils.arrayToString(testResult.getMethod().getGroupsDependedUpon()); if (!Utils.isStringEmpty(dependsOnStr)) { attributes.setProperty(XMLReporterConfig.ATTR_DEPENDS_ON_GROUPS, dependsOnStr); ConstructorOrMethod cm = testResult.getMethod().getConstructorOrMethod(); Test testAnnotation; if (cm.getMethod() != null) { testAnnotation = cm.getMethod().getAnnotation(Test.class);
Method testMethod = testResult.getMethod().getConstructorOrMethod().getMethod(); boolean beforeCallbacksExecuted = false;
@Override public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { if (method.isTestMethod()) { Method testMethod = method.getTestMethod().getConstructorOrMethod().getMethod(); TestCoverage.INSTANCE.setCurrentTestMethod(testMethod); } }
xsb.push("a", "name", Model.getTestResultName(tr)); xsb.pop("a"); xsb.addOptional(S, tr.getMethod().getMethodName(), C, "method-name"); if (tr.getParameters().length > 0) { StringBuilder sb = new StringBuilder(); boolean first = true; for (Object p : tr.getParameters()) { if (!first) sb.append(", "); first = false; String description = tr.getMethod().getDescription(); if (! Strings.isNullOrEmpty(description)) { xsb.push("em");
@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); } } }
void addSelenideErrorListener(ITestResult result) { boolean listenerAlreadyAdded = SelenideLogger.hasListener(LISTENER_SOFT_ASSERT); boolean hasSoftAssertListener = shouldIntercept(result.getTestClass().getRealClass()); boolean isTestMethod = shouldIntercept(result.getMethod().getConstructorOrMethod().getMethod()); if (hasSoftAssertListener && isTestMethod && !listenerAlreadyAdded) { SelenideLogger.addListener(LISTENER_SOFT_ASSERT, new ErrorsCollector()); } else if (hasSoftAssertListener && !listenerAlreadyAdded) { SelenideLogger.addListener(LISTENER_SOFT_ASSERT, new ErrorsCollector()); } }
private TestNgRunStateTracker.EventLogBuilder buildEventLog(ITestResult result, TestNgRunEvent event) { return(buildEventLog(result.getTestContext(), event)) .addData(METHOD_NAME, result.getMethod().getMethodName()) .addData(CLASS_NAME, result.getMethod().getRealClass().getCanonicalName()) .addData(CLASS_INSTANCE, result.getMethod().getInstance()) .addData(GROUPS_DEPENDED_ON, result.getMethod().getGroupsDependedUpon()) .addData(METHODS_DEPENDED_ON, result.getMethod().getMethodsDependedUpon()) .addData(GROUPS_BELONGING_TO, result.getMethod().getGroups()); }
@Override public int compare(ITestResult arg0, ITestResult arg1) { return arg0.getMethod().getMethodName().compareTo( arg1.getMethod().getMethodName()); }
private static String getName(ITestResult result) { String testName = result.getName(); String methodName = result.getMethod().getConstructorOrMethod().getName(); String name; if (testName.contains(methodName)) { name = methodName; } else { name = testName + "#" + methodName; } if (result.getParameters().length != 0) { name = name + "(" + Joiner.on(",").useForNull("null").join(getParameterNames(result.getParameters())) + ")"; } return name; }
private void resultDetail(IResultMap tests) { for (ITestResult result : tests.getAllResults()) { ITestNGMethod method = result.getMethod(); m_methodIndex++; String cname = method.getTestClass().getName(); m_out.println("<h2 id=\"m" + m_methodIndex + "\">" + cname + ":" + method.getMethodName() + "</h2>"); generateForResult(result, method); m_out.println("<p class=\"totop\"><a href=\"#summary\">back to summary</a></p>"); } }
private void updateGroups(ISuite suite, ITestResult tr) { String[] groups = tr.getMethod().getGroups(); m_groupsBySuiteName.putAll(suite.getName(), Arrays.asList(groups)); for (String group : groups) { m_methodsByGroup.put(group, tr.getMethod().getMethodName()); } }
private boolean isPartOfFactoryTest(IInvokedMethod method) { java.lang.reflect.Method testMethod = method.getTestMethod() .getConstructorOrMethod().getMethod(); if (testMethod.getGenericParameterTypes().length == 2 && testMethod.getGenericParameterTypes()[0] .equals(IBrowserConf.class) && testMethod.getGenericParameterTypes()[1] .equals(IProperty.class)) { return false; } return true; }