title: Why @AfterClass called after tests from another classes?
body: <p>I tried to run test cases in determined order but without luck. As I see methods annotated with <code>@AfterClass</code> runs after methods from another test:</p>
  
  <pre><code>Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNGMapConfigurator@558ee9d6
  RUN class com.example.testng.ITCaseOne.beforeClass()
  RUN class com.example.testng.ITCaseOne.someCase()
  RUN class com.example.testng.ITCaseTwo.beforeClass()
  RUN class com.example.testng.ITCaseTwo.someCase()
  RUN class com.example.testng.ITCaseOne.anotherCase()
  RUN class com.example.testng.ITCaseOne.afterClass()
  RUN class com.example.testng.ITCaseTwo.anotherCase()
  RUN class com.example.testng.ITCaseTwo.afterClass()
  Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.25 sec
  </code></pre>
  
  <p>And it fail because all <code>@Test</code> from <code>ITCaseTwo</code> must be called only after <code>ITCaseOne.afterClass()</code> (because I use Selenium and tests from one case should check appropriate page).</p>
  
  <p>My simple classes:</p>
  
  <pre><code>public class ITCaseOne {
  
      @BeforeClass
      public void beforeClass() {
          System.out.printf("RUN %s.beforeClass()\n", getClass());
      }
  
      @AfterClass(alwaysRun = true)
      public void afterClass() {
          System.out.printf("RUN %s.afterClass()\n", getClass());
      }
  
      @Test(groups = "std-one")
      public void someCase() {
          System.out.printf("RUN %s.someCase()\n", getClass());
      }
  
      @Test(groups = "logic-one", dependsOnGroups = "std-one")
      public void anotherCase() {
          System.out.printf("RUN %s.anotherCase()\n", getClass());
      }
  
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class ITCaseTwo {
  
      @BeforeClass
      public void beforeClass() {
          System.out.printf("RUN %s.beforeClass()\n", getClass());
      }
  
      @AfterClass(alwaysRun = true)
      public void afterClass() {
          System.out.printf("RUN %s.afterClass()\n", getClass());
      }
  
      @Test(groups = "std-two")
      public void someCase() {
          System.out.printf("RUN %s.someCase()\n", getClass());
      }
  
      @Test(groups = "logic-two", dependsOnGroups = "std-two")
      public void anotherCase() {
          System.out.printf("RUN %s.anotherCase()\n", getClass());
      }
  
  }
  </code></pre>
  
  <p>If it's important I use <code>maven-failsafe-plugin</code> 2.12 and <code>testng</code> 6.4</p>
  
  <p>(BTW, I also try to use suite file with <code>preserve-order="true"</code> but it doesn't work for me.)</p>
  
  <p>Thanks in advance!</p>