/** * @return A sorted array containing all the methods 'method' depends on */ public static List<ITestNGMethod> getMethodsDependedUpon(ITestNGMethod method, ITestNGMethod[] methods, Comparator<ITestNGMethod> comparator) { Graph<ITestNGMethod> g = GRAPH_CACHE.get(methods); if (g == null) { List<ITestNGMethod> parallelList = Lists.newArrayList(); List<ITestNGMethod> sequentialList = Lists.newArrayList(); g = topologicalSort(methods, sequentialList, parallelList, comparator); GRAPH_CACHE.put(methods, g); } List<ITestNGMethod> result = g.findPredecessors(method); return result; }
/** @return A sorted array containing all the methods 'method' depends on */ public static List<ITestNGMethod> getMethodsDependedUpon( ITestNGMethod method, ITestNGMethod[] methods, Comparator<ITestNGMethod> comparator) { Graph<ITestNGMethod> g = GRAPH_CACHE.get(methods); if (g == null) { List<ITestNGMethod> parallelList = Lists.newArrayList(); List<ITestNGMethod> sequentialList = Lists.newArrayList(); g = topologicalSort(methods, sequentialList, parallelList, comparator); GRAPH_CACHE.put(methods, g); } return g.findPredecessors(method); }
private static List<ITestNGMethod> sortMethods(boolean forTests, List<ITestNGMethod> allMethods, Comparator<ITestNGMethod> comparator) { List<ITestNGMethod> sl = Lists.newArrayList(); List<ITestNGMethod> pl = Lists.newArrayList(); ITestNGMethod[] allMethodsArray = allMethods.toArray(new ITestNGMethod[allMethods.size()]); // Fix the method inheritance if these are @Configuration methods to make // sure base classes are invoked before child classes if 'before' and the // other way around if they are 'after' if (!forTests && allMethodsArray.length > 0) { ITestNGMethod m = allMethodsArray[0]; boolean before = m.isBeforeClassConfiguration() || m.isBeforeMethodConfiguration() || m.isBeforeSuiteConfiguration() || m.isBeforeTestConfiguration(); MethodInheritance.fixMethodInheritance(allMethodsArray, before); } topologicalSort(allMethodsArray, sl, pl, comparator); List<ITestNGMethod> result = Lists.newArrayList(); result.addAll(sl); result.addAll(pl); return result; }
private static List<ITestNGMethod> sortMethods( boolean forTests, List<ITestNGMethod> allMethods, Comparator<ITestNGMethod> comparator) { List<ITestNGMethod> sl = Lists.newArrayList(); List<ITestNGMethod> pl = Lists.newArrayList(); ITestNGMethod[] allMethodsArray = allMethods.toArray(new ITestNGMethod[0]); // Fix the method inheritance if these are @Configuration methods to make // sure base classes are invoked before child classes if 'before' and the // other way around if they are 'after' if (!forTests && allMethodsArray.length > 0) { ITestNGMethod m = allMethodsArray[0]; boolean before = m.isBeforeClassConfiguration() || m.isBeforeMethodConfiguration() || m.isBeforeSuiteConfiguration() || m.isBeforeTestConfiguration(); MethodInheritance.fixMethodInheritance(allMethodsArray, before); } topologicalSort(allMethodsArray, sl, pl, comparator); List<ITestNGMethod> result = Lists.newArrayList(); result.addAll(sl); result.addAll(pl); return result; }