title: How to write TestNG annotations like 'before test, before method, before class, after class' for code
body: <p>I'm new to TestNG notations, can anyone help me with how can I write down TestNG test cases (testing annotations like before test, before method, before class, after class) for the following code.</p>
  <pre><code>package au.com.junitpractice;
  import java.util.ArrayList;
  import java.util.List;
  
  public class Stack {
   private List&lt;Integer&gt; integerList;
   private List&lt;Integer&gt; maxList;
   private int currentMax;
  
   public Stack() {
   integerList = new ArrayList&lt;Integer&gt;();
   maxList = new ArrayList&lt;Integer&gt;();
   currentMax = 0;
   }
  
   public void push(int value) {
   integerList.add(value);
  
   if(this.currentMax &lt; value) {
   this.currentMax = value;
   }
   maxList.add(currentMax);
   }
  
   public int pop() {
   int popVal = integerList.remove(integerList.size()-1);
   maxList.remove(maxList.size()-1);
  
   if(!maxList.isEmpty()) {
   currentMax = maxList.get(maxList.size() - 1);
   }
   return popVal;
   }
  
   public int getMax() {
   //return Collections.max(integerList);
   //return maxList.remove(maxList.size()-1);
   return currentMax;
   }
  
   public int getSize() {
   return integerList.size();
   }
  }
  </code></pre>