/** * {@inheritDoc} */ @Override public boolean canRunFromClass(IClass testClass) { return m_methodClass.isAssignableFrom(testClass.getRealClass()); }
/** {@inheritDoc} */ @Override public boolean canRunFromClass(IClass testClass) { return m_methodClass.isAssignableFrom(testClass.getRealClass()); }
private Set<Object> getInvocationResults(IClass testClass) { Class<?> cls = testClass.getRealClass(); Set<Object> set = null; //We need to continuously search till either our Set is not null (or) till we reached //Object class because it is very much possible that the test method is residing in a child class //and maybe the parent method has configuration methods which may have had a failure //So lets walk up the inheritance tree until either we find failures or till we //reached the Object class. while (!cls.equals(Object.class)) { set = m_classInvocationResults.get(cls); if (set != null) { break; } cls = cls.getSuperclass(); } if (set == null) { //This should never happen because we have walked up all the way till Object class //and yet found no failures, but our logic indicates that there was a failure somewhere up the //inheritance order. We don't know what to do at this point. throw new IllegalStateException("No failure logs for " + testClass.getRealClass()); } return set; }
private Set<Object> getInvocationResults(IClass testClass) { Class<?> cls = testClass.getRealClass(); Set<Object> set = null; // We need to continuously search till either our Set is not null (or) till we reached // Object class because it is very much possible that the test method is residing in a child // class // and maybe the parent method has configuration methods which may have had a failure // So lets walk up the inheritance tree until either we find failures or till we // reached the Object class. while (!cls.equals(Object.class)) { set = m_classInvocationResults.get(cls); if (set != null) { break; } cls = cls.getSuperclass(); } if (set == null) { // This should never happen because we have walked up all the way till Object class // and yet found no failures, but our logic indicates that there was a failure somewhere up // the // inheritance order. We don't know what to do at this point. throw new IllegalStateException("No failure logs for " + testClass.getRealClass()); } return set; }
private void init(IClass cls, ITestMethodFinder testMethodFinder, IAnnotationFinder annotationFinder, XmlTest xmlTest, XmlClass xmlClass) { log(3, "Creating TestClass for " + cls); iClass = cls; m_testClass = cls.getRealClass(); this.xmlTest = xmlTest; this.xmlClass = xmlClass; this.testMethodFinder = testMethodFinder; this.annotationFinder = annotationFinder; initTestClassesAndInstances(); initMethods(); }
boolean result = true; Class<?> cls = testClass.getRealClass();
private void init( IClass cls, ITestMethodFinder testMethodFinder, IAnnotationFinder annotationFinder, XmlTest xmlTest, XmlClass xmlClass) { log(3, "Creating TestClass for " + cls); iClass = cls; m_testClass = cls.getRealClass(); this.xmlTest = xmlTest; this.xmlClass = xmlClass; this.testMethodFinder = testMethodFinder; this.annotationFinder = annotationFinder; initTestClassesAndInstances(); initMethods(); }
private void processMethod(IConfiguration configuration, IClass ic, ConstructorOrMethod factoryMethod) { if (!factoryMethod.getEnabled()) { return; } ClassInfoMap moreClasses = processFactory(ic, factoryMethod); if (moreClasses.isEmpty()) { return; } TestNGClassFinder finder = new TestNGClassFinder(moreClasses, m_instanceMap, configuration, m_testContext, Collections.<Class<? extends IDataProviderListener>, IDataProviderListener>emptyMap()); for (IClass ic2 : finder.findTestClasses()) { putIClass(ic2.getRealClass(), ic2); } }
Injector getInjector(IClass iClass) { Annotation annotation = AnnotationHelper.findAnnotationSuperClasses(Guice.class, iClass.getRealClass()); if (annotation == null) { return null; } if (iClass instanceof TestClass) { iClass = ((TestClass)iClass).getIClass(); } if (!(iClass instanceof ClassImpl)) { return null; } Injector parentInjector = ((ClassImpl)iClass).getParentInjector(); Guice guice = (Guice) annotation; List<Module> moduleInstances = Lists.newArrayList(getModules(guice, parentInjector, iClass.getRealClass())); // Reuse the previous injector, if any Injector injector = context.getInjector(moduleInstances); if (injector == null) { injector = parentInjector.createChildInjector(moduleInstances); context.addInjector(moduleInstances, injector); } return injector; }
Class<?> realClass = cls.getRealClass(); TestListenerHelper.ListenerHolder listenerHolder = TestListenerHelper.findAllListeners(realClass, m_annotationFinder); if (listenerFactoryClass == null) {
private void processMethod( IConfiguration configuration, IClass ic, ConstructorOrMethod factoryMethod) { if (!factoryMethod.getEnabled()) { return; } ClassInfoMap moreClasses = processFactory(ic, factoryMethod); if (moreClasses.isEmpty()) { return; } TestNGClassFinder finder = new TestNGClassFinder( moreClasses, m_instanceMap, configuration, m_testContext, Collections.emptyMap()); for (IClass ic2 : finder.findTestClasses()) { putIClass(ic2.getRealClass(), ic2); } }
private static void generateReport(ITestResult result) { StringBuilder builder = new StringBuilder(); String clsname = result.getTestClass().getRealClass().getName() + "."; String methodname = result.getMethod().getMethodName() + "()"; builder.append(clsname).append(methodname); Object[] parameters = result.getParameters(); if (parameters != null && parameters.length != 0) { builder.append(" Parameters:").append(Arrays.toString(parameters)); } Throwable throwable = result.getThrowable(); builder.append("\nException:\n"); builder.append(Utils.shortStackTrace(throwable, false)); builder.append("\n\n"); System.err.println(builder.toString()); } }
Injector getInjector(IClass iClass) { Guice guice = AnnotationHelper.findAnnotationSuperClasses(Guice.class, iClass.getRealClass()); if (guice == null) { return null; } if (iClass instanceof TestClass) { iClass = ((TestClass) iClass).getIClass(); } if (!(iClass instanceof ClassImpl)) { return null; } Injector parentInjector = ((ClassImpl) iClass).getParentInjector(); List<Module> moduleInstances = Lists.newArrayList(getModules(guice, parentInjector, iClass.getRealClass())); // Reuse the previous injector, if any Injector injector = context.getInjector(moduleInstances); if (injector == null) { injector = parentInjector.createChildInjector(moduleInstances); context.addInjector(moduleInstances, injector); } return injector; }
private static String prettyMsg(ITestResult result) { return "Test method : " + result.getTestClass().getRealClass().getName() + "." + result.getMethod().getMethodName() + "()" + ", Parameters : " + Arrays.toString(result.getParameters()); }
Class<?> realClass = cls.getRealClass(); TestListenerHelper.ListenerHolder listenerHolder = TestListenerHelper.findAllListeners(realClass, m_annotationFinder);
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);
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()); } }
m_runInfo, m_xmlTest, classMap.getXmlClass(ic.getRealClass())); m_classMap.put(ic.getRealClass(), tc);
ListMultiMap<Class<?>, ITestResult> map = Maps.newListMultiMap(); for (ITestResult m : tests.getAllResults()) { map.put(m.getTestClass().getRealClass(), m);
setClassInvocationFailure(testClass.getRealClass(), instance); } else { setClassInvocationFailure(tm.getRealClass(), instance);