title: Get Suite Name at Runtime in TestNG
body: <p>How can I get the current running suite name at run time in my test case?  I am using the piece of code shown below for getting the current suite name.</p>
  
  <p>Listeners class:</p>
  
  <pre><code>public class SuiteListener implements ISuiteListener{
  
  private static ThreadLocal&lt;ISuite&gt; ACCESS = new ThreadLocal&lt;ISuite&gt;();
  
  public static ISuite getAccess() {
           return ACCESS.get();
      }
  
  @Override
  public void onFinish(ISuite suite) {
      ACCESS.set(null);
  }
  
  @Override
  public void onStart(ISuite arg0) {
      ACCESS.set(arg0);
  }
  
   }
  </code></pre>
  
  <p>Test Class:</p>
  
  <pre><code>    @Listeners({ SuiteListener.class })
  public class Practise {
  
      @DataProvider(name = "getXlsPath")
      public Object[][] createData() throws Exception {
          String [][] testCasesPaths=null;
          ISuite suiteListner = SuiteListener.getAccess();
          String runningSuite=suiteListner.getName();
          System.out.println(runningSuite);
          testCasesPaths[0][0]="1.xls";
          testCasesPaths[1][0]="2.xls";
          return testCasesPaths;
      }
  
      @Test(dataProvider="getXlsPath")
      public void test2(String xlsPath){
          System.out.println(xlsPath);
      }
  }
  </code></pre>
  
  <p>Testng xml:</p>
  
  <pre><code>&lt;suite name="tables" &gt;
  &lt;test name="vendor" &gt;
      &lt;classes&gt;
          &lt;class name="Practise" &gt;&lt;/class&gt;
      &lt;/classes&gt;
  &lt;/test&gt;
  </code></pre>
  
  <p></p>
  
  <p>The code works perfectly until I specify the <code>parallel="tests"</code> attribute in the suite:</p>
  
  <pre><code>&lt;suite name="tables" parallel="tests" &gt;
  </code></pre>
  
  <p>In this case I could not get the suite name--it's not executing.
  Can someone help me on this, to get the suite name?</p>