title: TestNG - Importing / running tests from different classes
body: <p>My scenario is:</p>
  
  <pre><code>public class ExampleTest extends AbstractExampleTest {
      @Test(dependsOnMethods={"someMethodFromAbstractExampleTest"}
      public void firstTest() {
          // Assert
      }
  
      // here I would like to call CommonTests
  }
  
  public class CommonTests {
      @Test
      public void sharedTest() {
          // Assert
      }
  }
  </code></pre>
  
  <p>The reason something like CommonTests exists, is that it will contain a repeated test sequence. The way I currently communicate information from ExampleTest to CommonTests is done via statics which seems to work, but probably not the best.</p>
  
  <p>This works fine if I call CommonTests programmatically according to the TestNG documentation. The issue I have with that is the results aren't logged within the runner of ExampleTest.</p>
  
  <pre><code>@Test
  public void actionBasedTest(ITestContext context) {
      TestListenerAdapter tla = new TestListenerAdapter();
      TestNG testng = new TestNG();
      testng.setTestClasses(new Class[] { ExampleAction.class });
      testng.addListener(tla);
      context.getSuite().addListener(tla);
      testng.run();
  }
  </code></pre>
  
  <p>The above is slightly better, but the reporting back is limited to something like "org.testng.TestRunner@####" and doesn't expose the test methods run.</p>
  
  <p>So my question is: can I run tests from another class(es) (not via inheritance) and get the results logged to the same listener?</p>
  
  <p>EDIT: I want to avoid testng.xml.</p>