title: TestNG - Read custom annotation details
body: <p><strong>Requirement:</strong> Read custom annotation details and generate report for all test classes of all suites.</p>
  
  <p><strong>Tried Solution:</strong>
  Implemented custom listener using <a href="https://static.javadoc.io/org.testng/testng/6.8.8/org/testng/ITestListener.html" rel="nofollow noreferrer">ITestListener</a>. But don't see direct way to get custom annotation details used as part of test methods apart from below way.</p>
  
  <pre><code>@Override
  public void onStart(ITestContext context) {
      ITestNGMethod[] testNGMethods = context.getAllTestMethods();
      for (ITestNGMethod testNgmethod : testNGMethods) {
          Method[] methods = testNgmethod.getRealClass().getDeclaredMethods();
          for (Method method : methods) {
              if (method.isAnnotationPresent(MyCustomAnnotation.class)) {
                  //Get required info
              }
          }
      }
  }
  </code></pre>
  
  <p>Inner loop triggers almost <code>n*n</code>(number of methods) times for each test class. I can control it by adding conditions.</p>
  
  <p>As I'm new bee to TestNG framework, would like to know the better solution to achieve my requirement i.e. generating report by reading custom annotation details from all test methods from all suites.</p>