title: How to execute code before TestNG for ie. building up the test suite
body: <p>i am using Selenium2 + TestNG + Maven2 + alot of other stuff.
  What I would like to do is to build the testng.xml (xml suite) on-the-fly upon
  test execution, because I would read those tests out of HP ALM QC via OpenTestArchitecture (OTA).
  Is there anyway to tell maven and surefire to NOT start TestNG immediately, instead to
  call a main method somewhere, where I could build my test suite via</p>
  
  <pre><code>XmlSuite xs = new XmlSuite();
  XmlTest xt = new XmlTest(xs);
  ...
  TestNG tng = new TestNG();
  tng.setXmlSuites(suites);
  tng.run();
  </code></pre>
  
  <p>the purpose is also to capture all types of exceptions to be able to write back the
  results from TestNG into HP ALM QC via OTA. Recently I had a exception from String.format and it killed my whole script because it happened in my TestNG @AfterMethod</p>
  
  <p>Thanks :)</p>