Fixed: TESTNG-67: @Configuration/@Factory methods in base class being ignored


diff --git a/.classpath b/.classpath
index bdd0247..0e7b246 100644
--- a/.classpath
+++ b/.classpath
@@ -9,9 +9,7 @@
 	<classpathentry kind="lib" path="3rdparty/ant-launcher.jar"/>
 	<classpathentry kind="lib" path="3rdparty/ant.jar"/>
 	<classpathentry kind="lib" path="3rdparty/qdox-1.6.1.jar"/>
-	<classpathentry kind="var" path="TOOLS15_LIB"/>
 	<classpathentry kind="lib" path="3rdparty/backport-util-concurrent-2.2.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
-	<classpathentry kind="lib" path="/home/cbeust/java/jdk1.5.0_09/jdk1.5.0/lib/tools.jar"/>
 	<classpathentry kind="output" path="z_build"/>
 </classpath>
diff --git a/CHANGES.txt b/CHANGES.txt
index fee5108..21529f4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,6 +3,7 @@
 Added: dataProviderThreadCount can be set from the command line and from ant (Adrian Grealish)
 Added: ITestAnnotation#setDataProvider
 Added: Assert#assertEquals() methods for Sets and Maps
+Fixed: TESTNG-67: @Configuration/@Factory methods in base class being ignored
 Fixed: Inner test classes were not excluded properly (Carsten Gubernator)
 Fixed: threadPoolSize without invocationCount was causing reporters not to be invoked
 Fixed: A @Factory throwing an exception did not cause any error
diff --git a/doc/documentation-main.html b/doc/documentation-main.html
index c61c544..31e4447 100644
--- a/doc/documentation-main.html
+++ b/doc/documentation-main.html
@@ -7,6 +7,17 @@
         <script type="text/javascript" src="http://beust.com/prettify.js"></script>
         <script type="text/javascript" src="banner.js"></script>
 
+      <script type="text/javascript" src="http://beust.com/scripts/shCore.js"></script>
+      <script type="text/javascript" src="http://beust.com/scripts/shBrushJava.js"></script>
+      <script type="text/javascript" src="http://beust.com/scripts/shBrushXml.js"></script>
+      <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shCore.css"/>
+      <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shThemeCedric.css"/>
+      <script type="text/javascript">
+        SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';
+        SyntaxHighlighter.defaults['gutter'] = false;
+        SyntaxHighlighter.all();
+      </script>
+
         <style type="text/css">
             /* Set the command-line table option column width. */
             #command-line colgroup.option {
@@ -523,20 +534,20 @@
 <a href="http://testng.org/dtd">HTML version</a>).</p><p>Here is an example <tt>testng.xml</tt> file:</p>
 
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" &gt;
  
 &lt;suite name="Suite1" verbose="1" &gt;
   &lt;test name="Nopackage" &gt;
     &lt;classes&gt;
-       &lt;class name="NoPackageTest"  /&gt;
+       &lt;class name="NoPackageTest" /&gt;
     &lt;/classes&gt;
   &lt;/test&gt;
 
-  &lt;test name="Regression1"   &gt;
+  &lt;test name="Regression1"&gt;
     &lt;classes&gt;
-      &lt;class name="test.sample.ParameterSample"  /&gt;
-      &lt;class name="test.sample.ParameterTest" /&gt;
+      &lt;class name="test.sample.ParameterSample"/&gt;
+      &lt;class name="test.sample.ParameterTest"/&gt;
     &lt;/classes&gt;
   &lt;/test&gt;
 &lt;/suite&gt;
@@ -544,7 +555,7 @@
 
 <p>You can specify package names instead of class names:</p>
 
-<pre class="prettyprint">
+<pre class="brush: xml; highlight: [5,6,7]">
 &lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" &gt;
 
 &lt;suite name="Suite1" verbose="1" &gt;
@@ -560,7 +571,7 @@
 <p>In this example, TestNG will look at all the classes in the package 
 	<tt>test.sample</tt> and will retain only classes that have TestNG annotations.</p><p>You can also specify groups and methods to be included and excluded:</p>
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;test name="Regression1"&gt;
   &lt;groups&gt;
     &lt;run&gt;
@@ -786,7 +797,7 @@
 belongs to the &quot;functest&quot; group, and additionally that a couple of methods 
 belong to the group &quot;checkintest&quot;:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public class Test1 {
   @Test(groups = { "functest", "checkintest" })
   public void testMethod1() {
@@ -799,13 +810,12 @@
   @Test(groups = { "functest" })
   public void testMethod3() {
   }
-
 }
 </pre>
 
 <p>Invoking TestNG with </p>
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;test name="Test1"&gt;
   &lt;groups&gt;
     &lt;run&gt;
@@ -823,7 +833,7 @@
 that some of your test methods should not be run on Linux, your test would look 
 like:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @Test
 public class Test1 {
   @Test(groups = { "windows.checkintest" }) 
@@ -843,7 +853,7 @@
 <p>
 You could use the following testng.xml to launch only the Windows methods:
 </p>
-<pre class="prettyprint">
+<pre class="brush: xml; highlight: [4,9]">
 &lt;test name="Test1"&gt;
   &lt;groups&gt;
     &lt;run&gt;
@@ -863,7 +873,7 @@
 
 <h4><a name="method-groups">Method groups</a></h4>You can also exclude or include individual methods:
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;test name="Test1"&gt;
   &lt;classes&gt;
     &lt;class name="example1.Test1"&gt;
@@ -888,7 +898,7 @@
 would define this in your property file:</p>
 
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;test name="Regression1"&gt;
   &lt;groups&gt;
     &lt;define name="functest"&gt;
@@ -921,14 +931,14 @@
 make these test methods belong to it.&nbsp; For example, in the above example, I 
 know that testMethod2() is now broken so I want to disable it:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @Test(groups = {"checkintest", "broken"} )
 public void testMethod2() {
 }
 </pre>
 <p>All I need to do now is to exclude this group from the run:
 
-<pre class="prettyprint">
+<pre class="brush: xml; highlight: 5">
 &lt;test name="Simple example"&gt;
   &lt;groups&gt;
     &lt;run&gt;
@@ -956,7 +966,7 @@
 <a name="partial-groups">5.4 - Partial groups</a></h4><p>You can define 
 groups at the class level and then add groups at the method level:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @Test(groups = { "checkin-test" })
 public class All {
 
@@ -993,7 +1003,7 @@
 If you are using simple values for your parameters, you can specify them in your 
 <tt>testng.xml</tt>:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @Parameters({ "first-name" })
 @Test
 public void testSingleString(String firstName) { 
@@ -1006,7 +1016,7 @@
 should receive the value of the XML parameter called <tt>first-name</tt><i>.</i>&nbsp; 
 This XML parameter is defined in <tt>testng.xml</tt>:<p>
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;suite name="My suite"&gt;
   &lt;parameter name="first-name"  value="Cedric"/&gt;
   &lt;test name="Simple example"&gt;
@@ -1015,7 +1025,7 @@
 
 <h4><span style="font-weight: 400">The same technique can be used for <tt>@Before/After </tt>and <tt>@Factory</tt> annotations:</span></h4>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @Parameters({ "datasource", "jdbcDriver" })
 @BeforeMethod
 public void beforeTest(String ds, String driver) {
@@ -1032,7 +1042,7 @@
 
 Parameters can be declared optional with the <a href="../javadocs/org/testng/annotations/Optional.html"><tt>Optional</tt></a> annotation:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @Parameters("db")
 @Test
 public void testNonExistentParameter(@Optional("mysql") String db) { ... }
@@ -1074,7 +1084,7 @@
 test.&nbsp; A Data Provider is a method on your class that returns an array of 
 array of objects.&nbsp; This method is annotated with @DataProvider:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 //This method will provide data to any test method that declares that its Data Provider
 //is named "test1"
 @DataProvider(name = "test1")
@@ -1106,7 +1116,7 @@
 <p>
 By default, the data provider will be looked for in the current test class or one of its base classes.  If you want to put your data provider in a different class, it needs to be a static method and you specify the class where it can be found in the <tt>dataProviderClass</tt> attribute:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public static class StaticProvider {
   @DataProvider(name = "create")
   public static Object[][] createData() {
@@ -1132,7 +1142,7 @@
 Here is an example of this feature for both JDK 1.4 and JDK5 (note that the JDK 1.4 example does not use Generics):
 
 
-<pre class="prettyprint">
+<pre class="brush: java">
 /**
  * @testng.data-provider name="test1"
  */
@@ -1141,9 +1151,9 @@
 )
 </pre>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @DataProvider(name = "test1")
-public Iterator<Object[]> createData() {
+public Iterator&lt;Object[]> createData() {
   return new MyIterator(DATA);
 } 
 </pre>
@@ -1156,7 +1166,7 @@
 <p>
 For example, the following code prints the name of the test method inside its <tt>@DataProvider</tt>:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @DataProvider(name = "dp")
 public Object[][] createData(Method m) {
   System.out.println(m.getName());  // print test method name
@@ -1182,7 +1192,7 @@
 
 Data providers can run in parallel with the attribute <tt>parallel</tt>:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @DataProvider(parallel = true)
 // ...
 </pre>
@@ -1190,7 +1200,7 @@
 Parallel data providers running from an XML file share the same pool of threads, which has a size of 10 by default.  You can modify this value in the <tt>&lt;suite&gt;</tt> tag of your XML file:
 
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;suite name="Suite1" data-provider-thread-count="20" &gt;
 ... 
 </pre>
@@ -1239,7 +1249,7 @@
 
 Here is an example of a hard dependency:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @Test
 public void serverStartedOk() {}
 
@@ -1251,7 +1261,7 @@
 serverStartedOk(), which guarantees that serverStartedOk() 
 will always be invoked first.</p><p>You can also have methods that depend on entire groups:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @Test(groups = { "init" })
 public void serverStartedOk() {}
 
@@ -1289,7 +1299,7 @@
 want to create a test method that will access a page on a Web site several 
 times, and you want to invoke it with different values:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public class TestWebServer {
   @Test(parameters = { "number-of-times" })
   public void accessPage(int numberOfTimes) {
@@ -1302,7 +1312,7 @@
 
 <tt>testng.xml:</tt></p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 &lt;test name="T1"&gt;
 &nbsp;&nbsp;&lt;parameter name="number-of-times" value="10"/&gt;
 &nbsp;&nbsp;&lt;class name= "TestWebServer" /&gt;
@@ -1322,7 +1332,7 @@
 <p>This can become quickly impossible to manage, so instead, you should use a 
 factory:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public class WebTestFactory {
   @Factory
   public Object[] createInstances() {
@@ -1336,7 +1346,7 @@
 
 and the new test class is now:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public class WebTest {
   private int m_numberOfTimes;
   public WebTest(int numberOfTimes) {
@@ -1356,7 +1366,7 @@
 contains the factory method, since the test instances themselves will be created 
 at runtime:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 &lt;class name="WebTestFactory" /&gt;
 </pre>
 
@@ -1379,7 +1389,7 @@
 
 The <tt>@Test</tt> annotation can be put on a class instead of a test method:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @Test
 public class Test1 {
   public void test1() {
@@ -1392,7 +1402,7 @@
 The effect of a class level <tt>@Test</tt> annotation is to make all the public methods of this class to become test methods even if they are not annotated.  You can still repeat the <tt>@Test</tt> annotation on a method if you want to add certain attributes.
 <p>
 For example:
-<pre class="prettyprint">
+<pre class="brush: java">
 @Test
 public class Test1 {
   public void test1() {
@@ -1416,15 +1426,15 @@
 instruct TestNG to run your tests in separate threads by using the <i>parallel</i> 
 attribute on the suite tag.  This attribute can take one of following values:
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;suite name="My suite" parallel="methods" thread-count="5"&gt;
 </pre>
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;suite name="My suite" parallel="tests" thread-count="5"&gt;
 </pre>
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;suite name="My suite" parallel="classes" thread-count="5"&gt;
 </pre>
 
@@ -1458,7 +1468,7 @@
 	<p><i>Note: the <tt>@Test</tt> attribute <tt>timeOut</tt> works in both 
 	parallel and non-parallel mode.</i></p></blockquote>You can also specify that a <tt>@Test</tt> method should be invoked from different threads.  You can use the attribute <tt>threadPoolSize</tt> to achieve this result:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @Test(threadPoolSize = 3, invocationCount = 10,  timeOut = 10000)
 public void testServer() {
 </pre>
@@ -1486,7 +1496,7 @@
 classes in the <tt>testng.classNames</tt> property and set the <tt>testng.junit</tt> property to 
 true:<br>
 <p></p>
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;test name="Test1"   junit="true"&gt;
   &lt;classes&gt;
     &lt;!-- ... --&gt;
@@ -1510,7 +1520,7 @@
 only difference is in the annotations, which use the popular XDoclet JavaDoc 
 annotation syntax:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public class SimpleTest {
  /**
   * @testng.before-class = "true"
@@ -1588,7 +1598,7 @@
 
 <p>You can invoke TestNG from your own programs very easily:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 TestListenerAdapter tla = new TestListenerAdapter();
 TestNG testng = new TestNG();
 testng.setTestClasses(new Class[] { Run2.class });
@@ -1602,7 +1612,7 @@
 <p>
 For example, suppose you want to create the following virtual file:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 &lt;suite name="TmpSuite" &gt;
   &lt;test name="TmpTest" &gt;
     &lt;classes&gt;
@@ -1614,7 +1624,7 @@
 
 You would use the following code:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 XmlSuite suite = new XmlSuite();
 suite.setName("TmpSuite");
 
@@ -1626,7 +1636,7 @@
 </pre>
 And then you can pass this <tt>XmlSuite</tt> to TestNG:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 List&lt;XmlSuite&gt; suites = new ArrayList&lt;XmlSuite&gt;();
 suites.add(suite);
 TestNG tng = new TestNG();
@@ -1648,7 +1658,7 @@
 
 	<p>If the <tt>&lt;include&gt;</tt> and <tt>&lt;exclude&gt;</tt> tags in <tt>testng.xml</tt> are not enough for your needs, you can use a <a href="http://beanshell.org">BeanShell</a> expression to decide whether a certain test method should be included in a test run or not. You specify this expression just under the <tt>&lt;test&gt;</tt> tag:</p>
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;test name="BeanShell test"&gt;
    &lt;method-selectors&gt;
      &lt;method-selector&gt;
@@ -1689,7 +1699,7 @@
 
 An Annotation Transformer is a class that implements the following interface:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public interface IAnnotationTransformer {
 
   /**
@@ -1717,13 +1727,13 @@
 
 Like all the other TestNG listeners, you can specify this class either on the command line or with ant:
 
-<pre class="prettyprint">
+<pre class="brush: java">
   java org.testng.TestNG -listener MyTransformer testng.xml
 </pre>
 
 or programmatically:
 
-<pre class="prettyprint">
+<pre class="brush: java">
   TestNG tng = new TestNG();
   tng.setAnnotationTransformer(new MyTransformer());
   // ...
@@ -1733,7 +1743,7 @@
 <p>
 For example, here is how you would override the attribute <tt>invocationCount</tt> but only on the test method <tt>invoke()</tt> of one of your test classes:
 
-<pre class="prettyprint">
+<pre class="brush: java">
   public class MyTransformer implements IAnnotationTransformer {
     public void transform(ITest annotation, Class testClass,
         Constructor testConstructor, Method testMethod)
@@ -1763,7 +1773,7 @@
 
 In order to give you more control on the methods that belong to the second category, TestNG defines the following interface:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public interface IMethodInterceptor {
   
   List&lt;IMethodInstance&gt; intercept(List&lt;IMethodInstance&gt; methods, ITestContext context);
@@ -1790,7 +1800,7 @@
 <p>
 For example, here is a Method Interceptor that will reorder the methods so that test methods that belong to the group "fast" are always run first:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public List&lt;IMethodInstance&gt; intercept(List&lt;IMethodInstance&gt; methods, ITestContext context) {
   List&lt;IMethodInstance&gt; result = new ArrayList&lt;IMethodInstance&gt;();
   for (IMethodInstance m : methods) {
@@ -1860,13 +1870,13 @@
 
 Here is how you can define listeners in your <tt>testng.xml</tt> file:
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;suite&gt;
 
-&lt;listeners&gt;
-  &lt;listener class-name="com.example.MyListener" /&gt;
-  &lt;listener class-name="com.example.MyMethodInterceptor" /&gt;
-&lt;/listeners&gt;
+  &lt;listeners&gt;
+    &lt;listener class-name="com.example.MyListener" /&gt;
+    &lt;listener class-name="com.example.MyMethodInterceptor" /&gt;
+  &lt;/listeners&gt;
 
 ...
 
@@ -1892,7 +1902,10 @@
 <li>
   Any @Before and @After methods can declare a parameter of type <tt>XmlTest</tt>, which contain the current <tt>&lt;test&gt;</tt> tag.
 <li>
-  Any @BeforeMethod can declare a parameter of type <tt>java.lang.reflect.Method</tt>.  This parameter will receive the test method that will be called once this @BeforeMethod finishes.
+  Any @BeforeMethod (and @AfterMethod) can declare a parameter of type
+  <tt>java.lang.reflect.Method</tt>.  This parameter will receive the
+  test method that will be called once this @BeforeMethod finishes (or
+  after the method as run for @AfterMethod).
 <li>
   Any @BeforeMethod can declare a parameter of type <tt>Object[]</tt>.  This parameter will receive the list of parameters that are about to be fed to the upcoming test method, which could be either injected by TestNG, such as <tt>java.lang.reflect.Method</tt> or come from a <tt>@DataProvider</tt>.
 <li>
@@ -1912,7 +1925,7 @@
 
 The listener <tt><a href="../javadocs/org/testng/IInvokedMethodListener.html">IInvokedMethodListener</a></tt> allows you to be notified whenever TestNG is about to invoke a test (annotated with <tt>@Test</tt>) or configuration (annotated with any of the <tt>@Before</tt> or <tt>@After</tt> annotation) method.  You need to implement the following interface:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public interface IInvokedMethodListener extends ITestNGListener {
   void beforeInvocation(IInvokedMethod method, ITestResult testResult);
   void afterInvocation(IInvokedMethod method, ITestResult testResult);
@@ -1953,7 +1966,7 @@
 mark the method as failed (remember to use -ea on the JVM if you are not seeing 
 the assertion errors).</p><p>Here is an example test method:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 @Test
 public void verifyLastName() {
   assert "Beust".equals(m_lastName) : "Expected name Beust, for" + m_lastName;
@@ -1963,7 +1976,7 @@
 TestNG also include JUnit's Assert class, which lets you perform 
 assertions on complex objects:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 import static org.testng.AssertJUnit.*;
 //...
 @Test
@@ -1998,7 +2011,7 @@
 
 Here is a listener that displays a "." for each passed test, a "F" for each failure and a "S" for each skip:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public class DotTestListener extends TestListenerAdapter {
   private int m_count = 0;
 
@@ -2059,7 +2072,7 @@
 
 The <a href="../javadocs/org/testng/IReporter.html"><tt>org.testng.IReporter</tt></a> interface only has one method:
 
-<pre class="prettyprint">
+<pre class="brush: java">
 public void generateReport(List&lt;<a href="../javadocs/org/testng/ISuite.html">ISuite</a>&gt; suites, String outputDirectory)
 </pre>
 
@@ -2076,7 +2089,7 @@
 and outputs an XML file that can then be fed to JUnitReport.  <a href="http://testng.org/test-report/junit-noframes.html">
 Here</a> is an example, and the ant task to create this report:
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;target name="reports"&gt;
   &lt;junitreport todir="test-report"&gt;
     &lt;fileset dir="test-output"&gt;
@@ -2114,7 +2127,7 @@
 <p>
 TestNG offers an XML reporter capturing TestNG specific information that is not available in JUnit reports. This is particulary useful when the user's test environment needs to consume XML results with TestNG-specific data that the JUnit format can't provide.  Below is a sample of the output of such a reporter:
 </p>
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;testng-results&gt;
     &lt;suite name=&quot;Suite1&quot;&gt;
         &lt;groups&gt;
diff --git a/doc/index.html b/doc/index.html
index 91fbc99..7534f31 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -1,12 +1,21 @@
 <html>
-   <head>
-       <title>TestNG - Welcome</title>
+  <head>
+    <title>TestNG - Welcome</title>
+      <link rel="stylesheet" href="testng.css" type="text/css" />
+      <link type="text/css" rel="stylesheet" href="http://beust.com/beust.css"  />
+      <script type="text/javascript" src="http://beust.com/prettify.js"></script>
+      <script type="text/javascript" src="http://testng.org/doc/banner.js"></script>
 
-       <link rel="stylesheet" href="testng.css" type="text/css" />
-       <link type="text/css" rel="stylesheet" href="http://beust.com/beust.css"  />
-       <script type="text/javascript" src="http://beust.com/prettify.js"></script>
-       <script type="text/javascript" src="http://testng.org/doc/banner.js"></script>
-     </head>
+      <script type="text/javascript" src="http://beust.com/scripts/shCore.js"></script>
+      <script type="text/javascript" src="http://beust.com/scripts/shBrushJava.js"></script>
+      <script type="text/javascript" src="http://beust.com/scripts/shBrushXml.js"></script>
+      <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shCore.css"/>
+      <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shThemeDefault.css"/>
+      <script type="text/javascript">
+        SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';
+        SyntaxHighlighter.all();
+      </script>
+    </head>
 
 <body onload="prettyPrint()">
 
@@ -67,7 +76,7 @@
 TestNG's features provides for a very intuitive and maintainable testing design.</p>
 <p>Here is a very simple test:</p>
 
-<pre class="prettyprint">
+<pre class="brush: java">
 package example1;
 
 import org.testng.annotations.*;
@@ -114,7 +123,7 @@
 file:
 
 
-<pre class="prettyprint">
+<pre class="brush: xml">
 &lt;project default="test"&gt;
 
  &lt;path id="cp"&gt;
diff --git a/src/main/org/testng/internal/ClassHelper.java b/src/main/org/testng/internal/ClassHelper.java
index e54fd78..75a818a 100644
--- a/src/main/org/testng/internal/ClassHelper.java
+++ b/src/main/org/testng/internal/ClassHelper.java
@@ -107,7 +107,7 @@
   public static Method findFactoryMethod(Class<?> cls, IAnnotationFinder finder) {
     Method result = null;
 
-    for (Method method : cls.getDeclaredMethods()) {
+    for (Method method : cls.getMethods()) {
       IAnnotation f = finder.findAnnotation(method, IFactoryAnnotation.class);
 
       if (null != f) {
diff --git a/src/main/org/testng/internal/FactoryMethod.java b/src/main/org/testng/internal/FactoryMethod.java
index d48866b..b6c6b42 100644
--- a/src/main/org/testng/internal/FactoryMethod.java
+++ b/src/main/org/testng/internal/FactoryMethod.java
@@ -36,7 +36,7 @@
                        ITestContext testContext) 
   {
     super(method, annotationFinder);
-    if (! instance.getClass().isAssignableFrom(method.getDeclaringClass())) {
+    if (! method.getDeclaringClass().isAssignableFrom(instance.getClass())) {
       throw new TestNGException("Mismatch between instance/method classes:"
           + instance.getClass() + " " + method.getDeclaringClass());
     }
diff --git a/test-14/v4/testng-single.xml b/test-14/v4/testng-single.xml
index 55a6850..d5c3f5d 100644
--- a/test-14/v4/testng-single.xml
+++ b/test-14/v4/testng-single.xml
@@ -11,7 +11,8 @@
     </groups>
 -->
     <classes>
-	  <class name="test.tmp.FactoryTest" >
+      <class name="test.tmp.RegisterCommandTest" >
+	  <class name="test.tmp.BeforeGroupTest" >
     </class>
     </classes>      
   </test>
diff --git a/test/src/test/factory/FactoryBase.java b/test/src/test/factory/FactoryBase.java
new file mode 100644
index 0000000..60e793c
--- /dev/null
+++ b/test/src/test/factory/FactoryBase.java
@@ -0,0 +1,13 @@
+package test.factory;
+
+import org.testng.annotations.Factory;
+
+public class FactoryBase {
+
+  @Factory
+  public Object[] create() {
+    return new Object[] {
+      new FactoryBaseSampleTest()
+    };
+  }
+}
diff --git a/test/src/test/factory/FactoryBaseSampleTest.java b/test/src/test/factory/FactoryBaseSampleTest.java
new file mode 100644
index 0000000..b1de892
--- /dev/null
+++ b/test/src/test/factory/FactoryBaseSampleTest.java
@@ -0,0 +1,9 @@
+package test.factory;
+
+import org.testng.annotations.Test;
+
+public class FactoryBaseSampleTest {
+
+  @Test
+  public void f() {}
+}
diff --git a/test/src/test/factory/FactoryChild.java b/test/src/test/factory/FactoryChild.java
new file mode 100644
index 0000000..83ffd2a
--- /dev/null
+++ b/test/src/test/factory/FactoryChild.java
@@ -0,0 +1,5 @@
+package test.factory;
+
+public class FactoryChild extends FactoryBase {
+
+}
diff --git a/test/src/test/factory/FactoryInSuperClassTest.java b/test/src/test/factory/FactoryInSuperClassTest.java
new file mode 100644
index 0000000..d380dd9
--- /dev/null
+++ b/test/src/test/factory/FactoryInSuperClassTest.java
@@ -0,0 +1,21 @@
+package test.factory;
+
+import org.testng.Assert;
+import org.testng.TestListenerAdapter;
+import org.testng.TestNG;
+import org.testng.annotations.Test;
+
+import test.SimpleBaseTest;
+
+public class FactoryInSuperClassTest extends SimpleBaseTest {
+
+  @Test
+  public void factoryInSuperClassShouldWork() {
+    TestNG tng = create(FactoryChild.class);
+    TestListenerAdapter tla = new TestListenerAdapter();
+    tng.addListener(tla);
+    tng.run();
+
+    Assert.assertEquals(tla.getPassedTests().size(), 1);
+  }
+}
diff --git a/test/src/test/tmp/A.java b/test/src/test/tmp/A.java
index 6b513f7..5f9f226 100644
--- a/test/src/test/tmp/A.java
+++ b/test/src/test/tmp/A.java
@@ -1,10 +1,11 @@
 package test.tmp;
 
+import org.testng.ITest;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-public class A {
+public class A implements ITest {
   
   @DataProvider
   public Object[][] dp() {
@@ -27,6 +28,10 @@
   public void g2() {
   }
 
+  public String getTestName() {
+    return "This is test A";
+  }
+
 //  @Test(groups = "mytest", dependsOnMethods = "g")
 //  public void f() {
 //  }
diff --git a/test/testng-single.xml b/test/testng-single.xml
index 45a6365..9d43595 100644
--- a/test/testng-single.xml
+++ b/test/testng-single.xml
@@ -1,53 +1,19 @@
 <!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
   
-<suite name="SingleSuite" verbose="3" parallel="false" thread-count="2"
-    data-provider-thread-count="3">
+<suite name="Single" verbose="1" parallel="false" thread-count="2">
 
-  <parameter name="factory-param" value="FactoryParam" />
-
-  <test name="Simple">
-<!-- 
-    <packages>
-      <package name="test.tmp.p1.*" />
-    </packages>
-         <groups>
-            <run>
-                <include name="b"/>
-            </run>
-        </groups>
- -->
-    <classes>
-      <class name="test.tmp.A" />
-      <class name="test.tmp.B" />
+  <test name="Single">
 <!--
-      <class name="test.tmp.A" />
-      <class name="test.jar.JarTest" />
-      <class name="test.expectedexceptions.ExpectedExceptionsTest" />
+    <groups>
+      <run>
+        <include name="g2" />
+      </run>
+    </groups>
 -->
-     </classes>
-  </test>
-
-
-<!-- 
-  <test name="Simple2">
     <classes>
-      <class name="test.tmp.B" />
-     </classes>
-  </test>
-  <test name="RetryAnalyzer">
-    <classes>
-      <class name="test.retryAnalyzer.RetryAnalyzerTest" />
-    </classes>
+      <class name="test.factory.FactoryInSuperClassTest" />
+    </classes>      
   </test>
 
-
-  <test name="InvocationCount">
-    <parameter name="parameter" value="parameter value" />
-    <classes>
-      <class name="test.parameters.BeforeSampleTest" />
-     </classes>
-  </test>
- -->
- 
 </suite>
 
diff --git a/test/testng.xml b/test/testng.xml
index a0d0747..781c9f8 100644
--- a/test/testng.xml
+++ b/test/testng.xml
@@ -242,6 +242,8 @@
       <class name="test.factory.FactoryWithDataProviderTest" />
       <class name="test.factory.FactoryOrderMainTest" />
       <class name="test.factory.FactoryFailureTest" />
+
+      <class name="test.factory.FactoryInSuperClassTest" />
     </classes>
   </test>