1 package test.listeners;
2 
3 import org.testng.IClassListener;
4 import org.testng.IMethodInstance;
5 import org.testng.ITestClass;
6 
7 import java.util.ArrayList;
8 import java.util.List;
9 
10 public class MyClassListener implements IClassListener {
11 
12   public static final List<String> beforeNames = new ArrayList<>();
13   public static final List<String> afterNames = new ArrayList<>();
14 
15   @Override
onBeforeClass(ITestClass testClass, IMethodInstance mi)16   public void onBeforeClass(ITestClass testClass, IMethodInstance mi) {
17     beforeNames.add(testClass.getRealClass().getSimpleName());
18   }
19 
20   @Override
onAfterClass(ITestClass testClass, IMethodInstance mi)21   public void onAfterClass(ITestClass testClass, IMethodInstance mi) {
22     afterNames.add(testClass.getRealClass().getSimpleName());
23   }
24 }
25