Skip to content
Browse files

XmlMethodSelector#includeMethod was always called before all the othe…

…r selectors, because it was being invoked from setTestMethods(). Fixed this by deferring this code until includeMethod is really called by TestNG, this time respecting the priorities of the other method selectors
  • Loading branch information...
1 parent 53072c4 commit 88718b42c53c78082beacf652819115c5ea2ec18 cbeust committed Jan 3, 2007
View
1 CHANGES.txt
@@ -1,6 +1,7 @@
===========================================================================
5.5
+Fixed: XmlMethodSelector was always run first regardless of its priority
Added: @BeforeGroups/@AfterGroups can live in classes without @Test methods
Added: DataProvider can now take an ITestContext parameter
Fixed: Wasn't parsing <selector-class-name> correctly
View
26 src/main/org/testng/IClass.java
@@ -10,43 +10,21 @@
public interface IClass extends Serializable {
/**
- * Returns this test class' name. This is the name of the corresponding Java class.
- * @return this test class' name.
+ * @return this test class name. This is the name of the
+ * corresponding Java class.
*/
String getName();
/**
- * Returns the Java class corresponding to this IClass.
* @return the Java class corresponding to this IClass.
*/
Class getRealClass();
- /**
- * TODO cquezel JavaDoc.
- *
- * @param create
- * @return
- */
Object[] getInstances(boolean create);
- /**
- * TODO cquezel JavaDoc.
- *
- * @return
- */
int getInstanceCount();
- /**
- * TODO cquezel JavaDoc.
- *
- * @return
- */
long[] getInstanceHashCodes();
- /**
- * TODO cquezel JavaDoc.
- *
- * @param instance
- */
void addInstance(Object instance);
}
View
11 src/main/org/testng/TestListenerAdapter.java
@@ -8,7 +8,16 @@
/**
- * Simple ITestListener adapter.
+ * A simple ITestListener adapter that stores all the tests
+ * that were run. You can retrieve these results with the
+ * following methods:
+ * getPassedTests()
+ * getFailedTests()
+ * getSkippedTests()
+ *
+ * If you extend this class in order to override any of these
+ * methods, remember to call their super equivalent if you want
+ * this list of tests to be maintained.
*
* @author Cedric Beust, Aug 6, 2004
* @author <a href='mailto:the_mindstorm@evolva.ro'>Alexandru Popescu</a>
View
8 src/main/org/testng/TestRunner.java
@@ -254,7 +254,9 @@ private void initMethods() {
m_xmlTest,
m_annotationFinder);
ITestMethodFinder testMethodFinder= new TestNGMethodFinder(m_runInfo, m_annotationFinder);
-
+
+ m_runInfo.setTestMethods(testMethods);
+
//
// Initialize TestClasses
//
@@ -277,8 +279,6 @@ private void initMethods() {
Map<String, List<ITestNGMethod>> beforeGroupMethods= MethodHelper.findGroupsMethods(m_classMap.values(), true);
Map<String, List<ITestNGMethod>> afterGroupMethods= MethodHelper.findGroupsMethods(m_classMap.values(), false);
-
-
//
// Walk through all the TestClasses, store their method
// and initialize them with the correct ITestClass
@@ -298,8 +298,6 @@ private void initMethods() {
fixMethodsWithClass(tc.getAfterGroupsMethods(), tc,
MethodHelper.uniqueMethodList(afterGroupMethods.values()));
}
-
- m_runInfo.setTestMethods(testMethods);
//
// Sort the methods
View
18 src/main/org/testng/internal/XmlMethodSelector.java
@@ -39,6 +39,13 @@
private Map<String, String> m_includedMethods = new HashMap<String, String>();
public boolean includeMethod(ITestNGMethod tm, boolean isTestMethod) {
+ ppp("XML METHOD SELECTOR " + tm + " " + m_isInitialized);
+
+ if (! m_isInitialized) {
+ m_isInitialized = true;
+ init();
+ }
+
boolean result = false;
if (null != m_expression) {
result = includeMethodFromExpression(tm, isTestMethod);
@@ -339,17 +346,24 @@ private static void ppp(String s) {
public void setExpression(String expression) {
m_expression = expression;
}
+
+ private boolean m_isInitialized = false;
+ private List<ITestNGMethod> m_testMethods = null;
public void setTestMethods(List<ITestNGMethod> testMethods) {
+ m_testMethods = testMethods;
+ }
+
+ private void init() {
String[] groups = m_includedGroups.keySet().toArray(new String[m_includedGroups.size()]);
Set<String> groupClosure = new HashSet<String>();
Set<ITestNGMethod> methodClosure = new HashSet<ITestNGMethod>();
List<ITestNGMethod> includedMethods = new ArrayList<ITestNGMethod>();
- for (ITestNGMethod m : testMethods) {
+ for (ITestNGMethod m : m_testMethods) {
if (includeMethod(m, true)) includedMethods.add(m);
}
- MethodHelper.findGroupTransitiveClosure(this, includedMethods, testMethods,
+ MethodHelper.findGroupTransitiveClosure(this, includedMethods, m_testMethods,
groups, groupClosure, methodClosure);
// If we are asked to include or exclude specific groups, calculate
View
2 test/testng-single.xml
@@ -18,7 +18,7 @@
</groups>
-->
<classes>
- <class name="test.dataprovider.TestContextTest" />
+ <class name="test.annotationtransformer.AnnotationTransformerTest" />
</classes>
</test>

0 comments on commit 88718b4

Please sign in to comment.
Something went wrong with that request. Please try again.