title: How to set invocation count during execution for the method using TestNG & Java
body: <p>I am having one test method, which I am manually executing for 200 times. </p>
  
  <pre><code>@Test(priority=2, invocationCount = 200)
  public void inviteTalents() throws InterruptedException
  {
    logger.log(Status.INFO, "Count " + logins[count]);
  }
  </code></pre>
  
  <p>How can I set the invocation count variable? I have tried something like this, but doesn't work. Any help?</p>
  
  <pre><code>  @BeforeMethod
    public void setUp(Method method, ITestContext context) {
  
      if(method.getName().equals("test3"))
      {
          ITestNGMethod currentTestNGMethod = null;
          for (ITestNGMethod testNGMethod : context.getAllTestMethods())
          {
            if (testNGMethod.getInstance() == this)
            {
              currentTestNGMethod = testNGMethod;
              break;
            }
          }
          currentTestNGMethod.setInvocationCount(count);  
      }
    }
  </code></pre>