title: Order of Maven+Surefire+Testng - BeforeClass, BeforeTest, Test, Test, AfterTest, AfterClass
body: <p>I expected the following output:</p>
  
  <pre><code>Running TestSuite
  [DEBUG] beforeClass
  [DEBUG] beforeTest
  [DEBUG] test
  [DEBUG] afterTest
  [DEBUG] beforeTest
  [DEBUG] test
  [DEBUG] afterTest
  [DEBUG] afterClass
  </code></pre>
  
  <p>But instead, this actually happens. Notice 2 problems: BeforeClass runs <em>after</em> BeforeTest. Second, Before/AfterTest runs <em>once</em>.</p>
  
  <pre><code>Running TestSuite
  [DEBUG] beforeTest
  [DEBUG] beforeClass
  [DEBUG] test
  [DEBUG] test
  [DEBUG] afterClass
  [DEBUG] afterTest
  </code></pre>
  
  <p>Here's the code.</p>
  
  <pre><code>import org.testng.annotations.AfterClass;
  import org.testng.annotations.AfterTest;
  import org.testng.annotations.BeforeClass;
  import org.testng.annotations.BeforeTest;
  import org.testng.annotations.Test;
  public class TestNgAnnoTest {
     @BeforeClass
     public void beforeClass(){
        System.out.println("beforeClass");
     }
     @BeforeTest
     public void beforeTest(){
        System.out.println("beforeTest");
     }
     @Test
     public void test1(){
        System.out.println("test");
     }
     @Test
     public void test2(){
        System.out.println("test");
     }
     @AfterTest
     public void afterTest(){
        System.out.println("afterTest");
  
     }
     @AfterClass
     public void afterClass(){
        System.out.println("afterClass");
     }
  }
  </code></pre>
  
  <p>For anyone curious about tool versions:
  java macosx/1.6.0_22, mvn: 2.2.1, surefire 2.6, testng 5.14.2</p>