title: TestNG Annotations order
body: <p>I have a question about the order of operations with TestNG annotations... I have the following code:</p>
  
  <pre><code>public class AnnotationsTest {
  
      @BeforeSuite(alwaysRun = true)
      public static void beforeSuite() {
          System.out.println("@BeforeSuite");
      }
  
      @BeforeClass(alwaysRun = true)
      public static void beforeClass() {
          System.out.println("@BeforeClass");
      }
  
      @BeforeTest(alwaysRun = true)
      public static void beforeTest() {
          System.out.println("@BeforeTest");
      }
  
      @BeforeMethod(alwaysRun = true)
      public static void beforeMethod() {
          System.out.println("@BeforeMethod");
      }
  
      @AfterSuite(alwaysRun = true)
      public static void afterSuite() {
          System.out.println("@AfterSuite");
      }
  
      @AfterClass(alwaysRun = true)
      public static void afterClass() {
          System.out.println("@AfterClass");
      }
  
      @AfterTest(alwaysRun = true)
      public static void afterTest() {
          System.out.println("@AfterTest");
      }
  
      @AfterMethod(alwaysRun = true)
      public static void afterMethod() {
          System.out.println("@AfterMethod");
      }
  
      @Test
      public void test() {
          System.out.println("Test");
      }
  
      @Test
      public void test2() {
          System.out.println("Test2");
      }
  }
  </code></pre>
  
  <p>My output is the following:</p>
  
  <p><img src="https://i.stack.imgur.com/89zbG.png" alt="enter image description here"></p>
  
  <p>My question is, why is @AfterTest method not run after each @Test annotation? Does TestNG treat the entire class as the 'Test'? It seems like this is the case because the @BeforeTest and @AfterTest are outside of the @BeforeClass and @AfterClass, but I wanted to be sure I understand. I assume I could use the @BeforeMethod and @AfterMethod in this case to execute before and after the test1 and test2 in this class. Thanks!</p>