@Override public Object[] getInstances(boolean create) { return iClass.getInstances(create); }
@Override public Object[] getInstances(boolean create, String errorMsgPrefix) { return iClass.getInstances(create, this.m_errorMsgPrefix); }
@Override public Object[] getInstances(boolean create) { return iClass.getInstances(create); }
default Object[] getInstances(boolean create, String errorMsgPrefix) { return getInstances(create); }
private static Object computeParameters(Map<Class<?>, IClass> classes, Class<?> ec, IObjectFactory factory) throws NoSuchMethodException, IllegalAccessException, InstantiationException { // Create an instance of the enclosing class so we can instantiate // the nested class (actually, we reuse the existing instance). IClass enclosingIClass = classes.get(ec); if (enclosingIClass == null) { return ec.newInstance(); } Object[] enclosingInstances = enclosingIClass.getInstances(false); if (enclosingInstances == null || enclosingInstances.length == 0) { return factory.newInstance(ec.getConstructor(ec)); } return enclosingInstances[0]; }
public static ITestNGListenerFactory createListenerFactory(TestNGClassFinder finder, Class<? extends ITestNGListenerFactory> factoryClass) { ITestNGListenerFactory listenerFactory = null; try { if (finder != null) { IClass ic = finder.getIClass(factoryClass); if (ic != null) { listenerFactory = (ITestNGListenerFactory) ic.getInstances(false)[0]; } } if (listenerFactory == null) { listenerFactory = factoryClass != null ? factoryClass.newInstance() : null; } return listenerFactory; } catch (Exception ex) { throw new TestNGException("Couldn't instantiate the ITestNGListenerFactory: " + ex); } }
public static ITestNGListenerFactory createListenerFactory( TestNGClassFinder finder, Class<? extends ITestNGListenerFactory> factoryClass) { ITestNGListenerFactory listenerFactory = null; try { if (finder != null) { IClass ic = finder.getIClass(factoryClass); if (ic != null) { listenerFactory = (ITestNGListenerFactory) ic.getInstances(false)[0]; } } if (listenerFactory == null) { listenerFactory = factoryClass != null ? factoryClass.newInstance() : null; } return listenerFactory; } catch (Exception ex) { throw new TestNGException("Couldn't instantiate the ITestNGListenerFactory: " + ex); } }
/** * 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()]); }
private ClassInfoMap processFactory(IClass ic, ConstructorOrMethod factoryMethod) { Object[] theseInstances = ic.getInstances(false); if (theseInstances.length == 0) { theseInstances = ic.getInstances(true);
/** * 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[0]); }
Object[] enclosingInstances; if (null != enclosingIClass) { enclosingInstances = enclosingIClass.getInstances(false); if ((null == enclosingInstances) || (enclosingInstances.length == 0)) { Object o = objectFactory.newInstance(ec.getConstructor(parameterTypes));
private ClassInfoMap processFactory(IClass ic, ConstructorOrMethod factoryMethod) { Object[] theseInstances = ic.getInstances(false);
m_testMethods = createTestMethods(methods); for (Object instance : iClass.getInstances(false)) { m_beforeSuiteMethods = ConfigurationMethod .createSuiteConfigurationMethods(testMethodFinder.getBeforeSuiteMethods(m_testClass),
m_testMethods = createTestMethods(methods); for (Object eachInstance : iClass.getInstances(false)) { Object instance = IParameterInfo.embeddedInstance(eachInstance); m_beforeSuiteMethods =
/** * Workaround for {@link ITestResult#getInstance()} issue. Skipped * 'deppendsOnMethod' results return <code>null</code> instead of test * instance * <p/> * * Workaround doesn't help for factory created instances. * * @param result The test class used this object is a result for * @return the test instance */ public Object getTestInstance(ITestResult result) { Object instance = result.getInstance(); if (instance == null) { Object[] testInstances = result.getTestClass().getInstances(false); if (testInstances.length == 1) { instance = testInstances[0]; } else { logger.warn("TestNG factory issue. " + "You have deppendsOn skipped method: " + result.getName()); } } return instance; }