title: Java - Turn off TestNG's default reporters programmatically
body: <p>I have an application where I need to execute my TestNG @Test annotated methods from my main method, and use ReportNG to generate reports.</p>
  
  <p>My main method looks like this:</p>
  
  <pre><code>public static void main(String args[])
  {
      TestNG myTestNG = new TestNG();
      XmlSuite mySuite = new XmlSuite();
      mySuite.setName("Sample Suite");
      mySuite.addListener("org.uncommons.reportng.HTMLReporter");
      mySuite.addListener("org.uncommons.reportng.JUnitXMLReporter");
      XmlTest myTest = new XmlTest(mySuite);
      myTest.setName("Sample Test");
      List&lt;XmlClass&gt; myClasses = new ArrayList&lt;XmlClass&gt;();
      myClasses.add(new XmlClass("com.varunmulloli.testng.SampleTest"));
      myTest.setXmlClasses(myClasses);
      List&lt;XmlTest&gt; myTests = new ArrayList&lt;XmlTest&gt;();
      myTests.add(myTest);
      mySuite.setTests(myTests);
      List&lt;XmlSuite&gt; mySuites = new ArrayList&lt;XmlSuite&gt;();
      mySuites.add(mySuite);
      myTestNG.setXmlSuites(mySuites);
      myTestNG.run();
  }
  </code></pre>
  
  <p>And my <code>SampleTest</code> class looks like this:</p>
  
  <pre><code>public class SampleTest 
  {
      @Test
      public void testSample() 
      {
          String str = "TestNG is working fine";
          assertEquals("TestNG is working fine", str);
      }
  }
  </code></pre>
  
  <p>The code runs fine, but in the test-output folder, I get the reports generated by the default TestNG reporter as well along with the ReportNG reports. How do I disable the default reporters programmatically? </p>
  
  <p><a href="https://stackoverflow.com/questions/5751416/turning-off-test-output-in-testng">Turning off test-output in TestNG</a> - This question is similar to mine, but it does not discuss about disabling it programmatically.</p>