title: Parallelizing classes and method in testng
body: <p>I have a usecase where I have to run certain test methods under one class dynamically.</p>
  
  <p>I am using <code>@factory</code> annotation for generating these test classes dynamically.</p>
  
  <p>I already have my test methods under the mentioned class running in parallel.</p>
  
  <p>How do I make the test classes and test methods both parallel? Is there anyway to do it as well?</p>
  
  <pre><code>public class FactoryClass {
  
      @Factory
      public Object[] factoryMethod() {
          return new Object[] { new TestClass(), new TestClass() }
      }
  }
  
  public class TestClass {
  
      @DataProvider(name = "firstDataProvider", parallel = true)
      public Object[] firstDataProvider() {
          return new Object[] { };
      }
  
      @DataProvider(name = "secondDataProvider", parallel = true)
      public Object[] secondDataProvider() {
          return new Object[] { };
      }
  
      @Test(dataProvider = "firstDataProvider")
      public void firstTestMethod(String arg) {
  
      }
  
      @Test(dataProvider = "secondDataProvider")
      public void secondTestMethod(String arg) {
  
      }
  }
  </code></pre>
  
  <p>test.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" &gt;
  &lt;suite name="Suite1" parallel="methods"  data-provider-thread-count="60"&gt;
      &lt;test name="test1"&gt;
          &lt;classes&gt;
              &lt;class name="com.amriteya.test.FactoryMain"&gt;&lt;/class&gt;     
          &lt;/classes&gt;
      &lt;/test&gt;
  &lt;/suite&gt;
  </code></pre>
  
  <p>Following is the layout of my classes. </p>
  
  <p>In <code>test.xml</code> I am setting parallel="methods" but it is not providing the right output for me.</p>