Refine search
@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 static String prettyMsg(ITestResult result) { return "Test method : " + result.getTestClass().getRealClass().getName() + "." + result.getMethod().getMethodName() + "()" + ", Parameters : " + Arrays.toString(result.getParameters()); }
/** * Create the test methods that belong to this class (rejects * all those that belong to a different class). */ private ITestNGMethod[] createTestMethods(ITestNGMethod[] methods) { List<ITestNGMethod> vResult = Lists.newArrayList(); for (ITestNGMethod tm : methods) { ConstructorOrMethod m = tm.getConstructorOrMethod(); if (m.getDeclaringClass().isAssignableFrom(m_testClass)) { for (Object o : iClass.getInstances(false)) { log(4, "Adding method " + tm + " on TestClass " + m_testClass); vResult.add(new TestNGMethod(/* tm.getRealClass(), */ m.getMethod(), annotationFinder, xmlTest, o)); } } else { log(4, "Rejecting method " + tm + " for TestClass " + m_testClass); } } return vResult.toArray(new ITestNGMethod[vResult.size()]); }
m_instanceName = m_testClass.getName(); if (null == m_throwable) { m_status = ITestResult.SUCCESS; m_name = m_method.getMethodName(); } else { if (m_instance instanceof ITest) { m_name = ((ITest) m_instance).getTestName(); } else if (testClass.getTestName() != null) { m_name = testClass.getTestName(); } else { String string = m_instance.toString(); m_name = getMethod().getMethodName(); try { if (!Object.class.getMethod("toString")
Object[] enclosingInstances; if (null != enclosingIClass) { enclosingInstances = enclosingIClass.getInstances(false); if ((null == enclosingInstances) || (enclosingInstances.length == 0)) { Object o = objectFactory.newInstance(ec.getConstructor(parameterTypes)); enclosingIClass.addInstance(o); enclosingInstances = new Object[] { o };
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());
@Override public void onTestFailure( ITestResult result ) { IClass clazz = result.getTestClass(); ReportEntry report = withException( clazz.getName(), result.getName(), new PojoStackTraceWriter( clazz.getRealClass().getName(), result.getMethod().getMethodName(), result.getThrowable() ) ); reporter.testFailed( report ); }
@Override public void onTestStart( ITestResult result ) { String clazz = result.getTestClass().getName(); String group = groupString( result.getMethod().getGroups(), clazz ); reporter.testStarting( new CategorizedReportEntry( clazz, result.getName(), group ) ); }
/** * After test method. * * @param result test result */ @AfterMethod(alwaysRun = true) public void afterMethod(ITestResult result) { if (!result.isSuccess()) { failed(result.getThrowable(), result.getTestClass().getRealClass(), result.getName()); } finished(result.getTestClass().getRealClass(), result.getName()); }
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 void log(ITestResult tr, String status) { System.out.printf( "%-50s %-17s %-8s %-15s %8s%n", tr.getName(), tr.getTestClass().getRealClass().getSimpleName() .replaceAll("Test", ""), status, Arrays.toString(tr.getMethod().getGroups()), (tr.getEndMillis() - tr.getStartMillis()) + "ms"); } }
private void failIfErrors(ITestResult result) { ErrorsCollector errorsCollector = SelenideLogger.removeListener(LISTENER_SOFT_ASSERT); if (errorsCollector != null) { try { errorsCollector.failIfErrors(result.getTestClass().getName() + '.' + result.getName()); } catch (AssertionError e) { result.setStatus(ITestResult.FAILURE); result.setThrowable(e); } } } }
@Override public void onTestStart(ITestResult tr) { System.out.println(); System.out.println("-----------------------------------------------"); System.out.println( "Starting " + tr.getTestClass().getName() + '.' + tr.getName() + " [Test #" + ++test_index + "]..."); }
@Override public void run(IHookCallBack hookCallBack, ITestResult testResult) { String testName = testResult.getInstanceName() + "." + testResult.getMethod().getMethodName(); String simpleName = testResult.getTestClass().getRealClass().getSimpleName(); registerThreadWithTest(testName, simpleName); try { hookCallBack.runTestMethod(testResult); } finally { unregisterThreadWithTest(); } }
rbc.addResult(tr.getTestClass().getRealClass(), tr); updateGroups(suite, tr); for (ITestResult tr : skipped) { m_statusBySuiteName.put(suite.getName(), "skipped"); rbc.addResult(tr.getTestClass().getRealClass(), tr); updateGroups(suite, tr); for (ITestResult tr : failed) { m_statusBySuiteName.put(suite.getName(), "failed"); rbc.addResult(tr.getTestClass().getRealClass(), tr); m_allFailedResults.add(tr); updateGroups(suite, tr);
private Map<String, List<ITestResult>> buildTestClassGroups(Set<ITestResult> testResults) { Map<String, List<ITestResult>> map = Maps.newHashMap(); for (ITestResult result : testResults) { String className = result.getTestClass().getName(); List<ITestResult> list = map.get(className); if (list == null) { list = Lists.newArrayList(); map.put(className, list); } list.add(result); } return map; }
@Override public void beforeConfiguration(ITestResult tr) { PrintStream printStream = new PrintStream(System.out); String testClassName = tr.getTestClass().getRealClass().getSimpleName(); if (tr.getMethod().isBeforeClassConfiguration() && !processedTestCases.contains(testClassName)) { printStream.println("\n" + BOLD + "// Start Running " + testClassName + " ...\n" + RESET); processedTestCases.add(testClassName); } }
private static boolean isGUITest(ITestResult testResult) { Class<?> realClass = testResult.getTestClass().getRealClass(); Method testMethod = testResult.getMethod().getMethod(); return GUITestFinder.isGUITest(realClass, testMethod); }
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); } }
@Override public String getName(ITestResult result) { // Start milliseconds of test long millis = result.getStartMillis(); int index = nextIndex(); // Test instance class name String clazz = result.getTestClass().getRealClass().getSimpleName(); // Test name (usually test method name) String test = result.getName(); String name = millis + "." + index + "-" + clazz + "." + test; return name; }