private static boolean hasInstance(ITestNGMethod baseClassMethod, ITestNGMethod derivedClassMethod) { Object baseInstance = baseClassMethod.getInstance(); Object derivedInstance = derivedClassMethod.getInstance(); return derivedInstance != null || baseInstance != null; }
@Override public Object getInstance() { return m_method.getInstance(); }
@Override public Object getInstance() { return m_method.getInstance(); }
@Override public Object getInstance() { return testNGMethod.getInstance(); }
private static boolean hasInstance( ITestNGMethod baseClassMethod, ITestNGMethod derivedClassMethod) { Object baseInstance = baseClassMethod.getInstance(); Object derivedInstance = derivedClassMethod.getInstance(); return derivedInstance != null || baseInstance != null; }
@Override public Object getInstance() { return testNGMethod.getInstance(); }
@Override public Object getInstance() { return m_method.getInstance(); }
private static boolean isSameInstance(ITestNGMethod baseClassMethod, ITestNGMethod derivedClassMethod) { Object baseInstance = baseClassMethod.getInstance(); Object derivedInstance = derivedClassMethod.getInstance(); return derivedInstance != null && baseInstance != null && baseInstance.getClass().isAssignableFrom(derivedInstance.getClass()); }
private static boolean isSameInstance( ITestNGMethod baseClassMethod, ITestNGMethod derivedClassMethod) { Object baseInstance = baseClassMethod.getInstance(); Object derivedInstance = derivedClassMethod.getInstance(); return derivedInstance != null && baseInstance != null && baseInstance.getClass().isAssignableFrom(derivedInstance.getClass()); }
public ClassMethodMap(List<ITestNGMethod> methods, XmlMethodSelector xmlMethodSelector) { for (ITestNGMethod m : methods) { // Only add to the class map methods that are included in the // method selector. We can pass a null context here since the selector // should already have been initialized if (xmlMethodSelector != null && ! xmlMethodSelector.includeMethod(null, m, true)) { continue; } Object instance = m.getInstance(); Collection<ITestNGMethod> l = classMap.get(instance); if (l == null) { l = new ConcurrentLinkedQueue<>(); classMap.put(instance, l); } l.add(m); } }
@Override public Object getInstance() { return tm.getInstance(); } });
@Override public Object getInstance() { return IParameterInfo.embeddedInstance(this.m_method.getInstance()); }
ParameterBag createParameters(ITestNGMethod testMethod, Map<String, String> parameters, Map<String, String> allParameterNames, ITestContext testContext, Object fedInstance) { return handleParameters(testMethod, testMethod.getInstance(), allParameterNames, parameters, testContext, fedInstance); }
@Override public <A extends IAnnotation> A findAnnotation(ITestNGMethod tm, Class<A> annotationClass) { final Class<? extends Annotation> a = m_annotationMap.get(annotationClass); if (a == null) { throw new IllegalArgumentException("Java @Annotation class for '" + annotationClass + "' not found."); } Method m = tm.getConstructorOrMethod().getMethod(); Class<?> testClass; if (tm.getInstance() == null) { testClass = m.getDeclaringClass(); } else { testClass = tm.getInstance().getClass(); } Annotation annotation = m.getAnnotation(a); if (annotation == null) { annotation = testClass.getAnnotation(a); } return findAnnotation(testClass, annotation, annotationClass, null, null, m, new Pair<>(annotation, m)); }
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { EasyMockSupport.injectMocks(method.getTestMethod().getInstance()); }
/** * @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; }
private static void log(ITestNGMethod method, String prefix) { if (method.getInstance() != null) { messages.add(prefix + method.getInstance().getClass().getName() + "." + method.getMethodName()); } else { messages.add(prefix + method.getMethodName()); } } }
private static Map<ITestNGMethod, Integer> searchForMethod( String methodName, DynamicGraph<ITestNGMethod> graph, Object instance) { for (Map.Entry<ITestNGMethod, Map<ITestNGMethod, Integer>> edge : graph.getEdges().entrySet()) { if (edge.getKey().getMethodName().equals(methodName) && (instance == null || edge.getKey().getInstance().toString().equals(instance.toString()))) { return edge.getValue(); } } return Maps.newHashMap(); }
@Override public List<IWorker<ITestNGMethod>> createWorkers(Arguments arguments) { ListMultiMap<Object, ITestNGMethod> lmm = Maps.newSortedListMultiMap(); for (ITestNGMethod m : arguments.getMethods()) { lmm.put(m.getInstance(), m); } List<IWorker<ITestNGMethod>> result = Lists.newArrayList(); for (Map.Entry<Object, List<ITestNGMethod>> es : lmm.entrySet()) { List<IMethodInstance> methodInstances = MethodHelper.methodsToMethodInstances(es.getValue()); TestMethodWorker tmw = new TestMethodWorker(arguments.getInvoker(), methodInstances, arguments.getTestContext().getCurrentXmlTest().getSuite(), arguments.getTestContext().getCurrentXmlTest().getAllParameters(), arguments.getConfigMethods(), arguments.getClassMethodMap(), arguments.getTestContext(), arguments.getListeners()); result.add(tmw); } return result; } }
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()); }