title: Best Way to Write TestNG Tests where one Test depends on the output of another
body: <p>I have a <strong>TestA</strong> that executes calls to multiple WebServices (provided by a @DataProvider) and verifies the status of each.</p>
  
  <p><strong>TestB</strong> then verifies further attributes of the output generated from successful runs of <strong>TestA</strong>.</p>
  
  <p>To run these tests using <strong>TestNG</strong>, I tried two approaches:</p>
  
  <ol>
  <li>To use a @Factory to generate Test Classes created from the output of TestA, but factories appear to be created before any Tests e.g. <strong>TestA</strong> are run</li>
  <li>To store the output of TestA in an output collection, have TestA run at a higher <strong>priority</strong> then TestB, then have TestB use a DataProvider that retrieves its results from the output collection. This works and is similar to <a href="https://stackoverflow.com/questions/3115822/passing-output-of-one-test-method-to-another-method-testng">this type of approach</a> except it uses priority instead of DependsOn, which would skip TestB if <strong>any</strong> runs of TestA failed.</li>
  </ol>
  
  <p><strong>Questions</strong>:</p>
  
  <p>In case <strong>1</strong> above, is it possible to dynamically generate and run new test classes (like the Factory does) based on the output of a Test?</p>
  
  <p>If not, is case <strong>2</strong> above, the recommended TestNG way, or is there a better way to do this?</p>
  
  <p><strong>Update:</strong>
  I have also asked this question on <a href="http://groups.google.com/group/testng-users/browse_thread/thread/4cc6d556cc3b6a6c" rel="nofollow noreferrer">TestNG users group</a> as Cedric suggested</p>