/** * Extracts the map of groups and their corresponding methods from the <code>classes</code>. */ public static Map<String, List<ITestNGMethod>> findGroupsMethods(Collection<ITestClass> classes, boolean before) { Map<String, List<ITestNGMethod>> result = Maps.newHashMap(); for (ITestClass cls : classes) { ITestNGMethod[] methods = before ? cls.getBeforeGroupsMethods() : cls.getAfterGroupsMethods(); for (ITestNGMethod method : methods) { for (String group : before ? method.getBeforeGroups() : method.getAfterGroups()) { List<ITestNGMethod> methodList = result.get(group); if (methodList == null) { methodList = Lists.newArrayList(); result.put(group, methodList); } // NOTE(cbeust, 2007/01/23) // BeforeGroups/AfterGroups methods should only be invoked once. // I should probably use a map instead of a list for a contains(), but // this list should usually be fairly short if (! methodList.contains(method)) { methodList.add(method); } } } } return result; }
/** Extracts the map of groups and their corresponding methods from the <code>classes</code>. */ public static Map<String, List<ITestNGMethod>> findGroupsMethods( Collection<ITestClass> classes, boolean before) { Map<String, List<ITestNGMethod>> result = Maps.newHashMap(); for (ITestClass cls : classes) { ITestNGMethod[] methods = before ? cls.getBeforeGroupsMethods() : cls.getAfterGroupsMethods(); for (ITestNGMethod method : methods) { String[] grp = before ? method.getBeforeGroups() : method.getAfterGroups(); List<String> groups = Stream.concat(Arrays.stream(grp), Arrays.stream(method.getGroups())) .collect(Collectors.toList()); for (String group : groups) { List<ITestNGMethod> methodList = result.computeIfAbsent(group, k -> Lists.newArrayList()); // NOTE(cbeust, 2007/01/23) // BeforeGroups/AfterGroups methods should only be invoked once. // I should probably use a map instead of a list for a contains(), but // this list should usually be fairly short if (!methodList.contains(method)) { methodList.add(method); } } } } return result; }
public NoOpTestClass(ITestClass testClass) { m_testClass= testClass.getRealClass(); m_beforeSuiteMethods= testClass.getBeforeSuiteMethods(); m_beforeTestConfMethods= testClass.getBeforeTestConfigurationMethods(); m_beforeGroupsMethods= testClass.getBeforeGroupsMethods(); m_beforeClassMethods= testClass.getBeforeClassMethods(); m_beforeTestMethods= testClass.getBeforeTestMethods(); m_afterSuiteMethods= testClass.getAfterSuiteMethods(); m_afterTestConfMethods= testClass.getAfterTestConfigurationMethods(); m_afterGroupsMethods= testClass.getAfterGroupsMethods(); m_afterClassMethods= testClass.getAfterClassMethods(); m_afterTestMethods= testClass.getAfterTestMethods(); m_instances= testClass.getInstances(true); m_instanceHashes= testClass.getInstanceHashCodes(); m_xmlTest = testClass.getXmlTest(); m_xmlClass = testClass.getXmlClass(); }
public NoOpTestClass(ITestClass testClass) { m_testClass = testClass.getRealClass(); m_beforeSuiteMethods = testClass.getBeforeSuiteMethods(); m_beforeTestConfMethods = testClass.getBeforeTestConfigurationMethods(); m_beforeGroupsMethods = testClass.getBeforeGroupsMethods(); m_beforeClassMethods = testClass.getBeforeClassMethods(); m_beforeTestMethods = testClass.getBeforeTestMethods(); m_afterSuiteMethods = testClass.getAfterSuiteMethods(); m_afterTestConfMethods = testClass.getAfterTestConfigurationMethods(); m_afterGroupsMethods = testClass.getAfterGroupsMethods(); m_afterClassMethods = testClass.getAfterClassMethods(); m_afterTestMethods = testClass.getAfterTestMethods(); m_instances = testClass.getInstances(true); m_instanceHashes = testClass.getInstanceHashCodes(); m_xmlTest = testClass.getXmlTest(); m_xmlClass = testClass.getXmlClass(); }
fixMethodsWithClass(tc.getBeforeGroupsMethods(), tc, MethodHelper.uniqueMethodList(beforeGroupMethods.values())); fixMethodsWithClass(tc.getAfterGroupsMethods(), tc, MethodHelper.uniqueMethodList(afterGroupMethods.values()));
MethodHelper.uniqueMethodList(beforeGroupMethods.values())); fixMethodsWithClass( tc.getAfterGroupsMethods(), tc, MethodHelper.uniqueMethodList(afterGroupMethods.values()));