title: Implementing TestNg suite programmatically and executing it via maven surefire
body: <p>How to implement TestNG test suite using java instead of testng.xml. i follow following procedure but i cannot run it with the maven suefire plug in. </p>
  
  <p>Please help </p>
  
  <pre><code>  TestNG testNG = new TestNG();
      List&lt;XmlClass&gt; classList =new ArrayList&lt;XmlClass&gt;();
      List&lt;XmlTest&gt; testList = new ArrayList&lt;XmlTest&gt;();
      List&lt;XmlSuite&gt; suiteList= new ArrayList&lt;XmlSuite&gt;();
      List&lt;String&gt; suiteNameList = new ArrayList&lt;String&gt;();
      XmlTest xmlTest= new XmlTest();
      XmlSuite suite = new XmlSuite();
      XmlClass xmlClass = new XmlClass();
      xmlClass.setClass(bpsTestNg.class);
      classList.add(xmlClass);
      xmlTest.setClasses(classList);
      testList.add(xmlTest);
     suite.setTests(testList);
      suiteList.add(suite);
      suite.setName("sampleSuite1");
      suiteNameList.add("sampleSuite1")  ;
      suite.toXml();
      IConfiguration iConfiguration = null;
      SuiteRunner suiteRunner= new SuiteRunner(iConfiguration,suite,".");
      suiteRunner.run();
  </code></pre>
  
  <p>Thank You,
  Dharshana.  </p>