title: How To Ensure an @Test Method Always Runs Before Any Others Regardless of Class, Suite or Group?
body: <p>My reading of the TestNG docs suggests that if I have a test method marked like this:</p>
  
  <pre><code>  @BeforeSuite(alwaysRun = true)
    @Test
    public void MyTestMethod { ... }
  </code></pre>
  
  <p>then <code>MyTestMethod</code> would run before any other test defined anywhere, regardless of class, suite or group. But that does not seem to be the case.</p>
  
  <p>Is there a way to make a test method run unconditionally before everything else? (And that if it fails no other tests will be run.)</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>The test class:</p>
  
  <pre><code>class Suite_Setup
  extends BaseTestSuite
  {
    @BeforeSuite(alwaysRun = true)
    def setup() {
      System.out.println("Conducting test suite setup...")
  
      // Verify that the internal API is configured properly and that the API host is available...
      new Action(ApiHostname, new BasicCookieStore)
    }
  }
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>The answer:</p>
  
  <p>We generate our own TestNG.xml files (automatically) and the @BeforeSuite method was not being included in it. Once it was included, <code>@BeforeSuite</code> had the expected effect.</p>
  
  <p>However, it does appear that both <code>@BeforeSuite</code> (and presumably other <code>@Before...</code> and <code>@After...</code> annotations) <em>can</em> be mixed with <code>@Test</code> and rather than inhibiting the execution of the annotated method, they cause it to run <em>more than once!</em></p>
  
  <p>Also, I remiss in not indicating which version of TestNG I'm using. It's 6.2.</p>