1
package org.testng.internal;
3
import java.io.Serializable;
4
import java.util.ArrayList;
5
import java.util.Collections;
8
import org.testng.IMethodSelector;
9
import org.testng.IMethodSelectorContext;
10
import org.testng.ITestNGMethod;
13
* This class contains all the information needed to determine
14
* what methods should be run. It gets invoked by the TestRunner
15
* and then goes through its list of method selectors to decide what methods
18
* @author <a href="mailto:cedric@beust.com">Cedric Beust</a>
20
public class RunInfo implements Serializable {
21
transient private List<MethodSelectorDescriptor>
22
m_methodSelectors = new ArrayList<MethodSelectorDescriptor>();
24
public void addMethodSelector(IMethodSelector selector, int priority) {
25
Utils.log("RunInfo", 3, "Adding method selector: " + selector + " priority: " + priority);
26
MethodSelectorDescriptor md = new MethodSelectorDescriptor(selector, priority);
27
m_methodSelectors.add(md);
31
* @return true as soon as we fond a Method Selector that returns
32
* true for the method "tm".
34
public boolean includeMethod(ITestNGMethod tm, boolean isTestMethod) {
35
Collections.sort(m_methodSelectors);
36
boolean foundNegative = false;
37
IMethodSelectorContext context = new DefaultMethodSelectorContext();
39
boolean result = false;
40
for (MethodSelectorDescriptor mds : m_methodSelectors) {
41
// If we found any negative priority, we break as soon as we encounter
42
// a selector with a positive priority
43
if (! foundNegative) foundNegative = mds.getPriority() < 0;
44
if (foundNegative && mds.getPriority() >= 0) break;
47
IMethodSelector md = mds.getMethodSelector();
48
result = md.includeMethod(context, tm, isTestMethod);
49
if (context.isStopped()) {
53
// This selector returned false, move on to the next
59
public static void ppp(String s) {
60
System.out.println("[RunInfo] " + s);
63
public void setTestMethods(List<ITestNGMethod> testMethods) {
64
for (MethodSelectorDescriptor mds : m_methodSelectors) {
65
mds.setTestMethods(testMethods);