title: Need a way for tests to run sequentially in TestNG using xmlSuites
body: <p>I do not run my testcases through testng xml but use</p>
  
  <pre><code>TestListener listener=new TestListener();
      XmlSuite suite=new XmlSuite();
      suite.setName("Test Results");
      suite.setParallel(ParallelMode.NONE);
      suite.setThreadCount(Integer.parseInt(TestProperties.THREAD_COUNT.toString()));
      List&lt;XmlSuite&gt; suits=new ArrayList&lt;XmlSuite&gt;();
      suits.add(suite);
  
  
      List&lt;XmlPackage&gt; xpackage=new ArrayList&lt;XmlPackage&gt;();
      xpackage.add(new XmlPackage(TestProperties.TESTNG_PACKAGE.toString()));
  
  
      XmlTest test=new XmlTest(suite);
      test.setPackages(xpackage);
      //test.setParallel(ParallelMode.NONE);
      String groups=TestProperties.TESTNG_GROUP.toString();
      System.out.println("groups are:"+groups);
      String groupArray[]=groups.split(",");
      List&lt;String&gt; includedGroups=new ArrayList&lt;String&gt;();
      includedGroups.addAll(Arrays.asList(groupArray));
      test.setIncludedGroups(includedGroups);
  
  
      TestNG tng=new TestNG();
      tng.setOutputDirectory("test-output");
      tng.setXmlSuites(suits);
      //tng.addListener((ITestNGListener) listener);
      tng.run();
      System.exit(0)
  </code></pre>
  
  <p>I need my tests to run sequentially because of a lot of factors. I tried giving parallelMode.none, preserve order etc, but my testcases are being run in a weird way usually numerical. For eg after 200, my testcase order in code would be 211,212,213 etc and after that 201,202 etc. I need it run in that order. But right now, after 200, the testcase run would be 201. How can i make the testcase run with the order in which they are specified.</p>
  
  <p>I also tried giving priority to the testcases 211,212 etc, but that too didnt work. I added method inteceptor but my line number always give 1.</p>
  
  <pre><code>public class PriorityInterceptor implements IMethodInterceptor {
  
  public List&lt;IMethodInstance&gt; intercept(List&lt;IMethodInstance&gt; methods, ITestContext context) {
  
      Comparator&lt;IMethodInstance&gt; comparator = new Comparator&lt;IMethodInstance&gt;() {
          private int getLineNo(IMethodInstance mi) {
          int result = 0;
  
          String methodName = mi.getMethod().getMethodName();
          String className  = mi.getMethod().getConstructorOrMethod().getDeclaringClass().getCanonicalName();
          ClassPool pool    = ClassPool.getDefault();
  
          try {
              CtClass cc        = pool.get(className);
              CtMethod ctMethod = cc.getDeclaredMethod(methodName);
              System.out.println(methodName);
              result            = ctMethod.getMethodInfo().getLineNumber(0);
              System.out.println("result:"+result+"and method:"+ctMethod);
          } catch (NotFoundException e) {
              e.printStackTrace();
          }
  
          return result;
          }
  
          public int compare(IMethodInstance m1, IMethodInstance m2) {
              System.out.println(getLineNo(m1) - getLineNo(m2));
          return getLineNo(m1) - getLineNo(m2);
          }
      };
  
      IMethodInstance[] array = methods.toArray(new IMethodInstance[methods.size()]);
      Arrays.sort(array, comparator);
      System.out.println("22222222222222222222222222222222222222222222222222222222");
      System.out.println(Arrays.asList(array));
      return Arrays.asList(array);
      }
  </code></pre>