title: TestNG @AfterMethod for a specific group is running after each method in Eclipse
body: <p>I don't get how the grouping works in TestNG, I have this code :</p>
  
  <pre><code>    @AfterMethod(groups = { "refreshPage" })
      public void refresh() throws IOException {
          driver.navigate().refresh();
      }
  
      @Test
      public void test1() {
  
      }
  
      @Test(groups = { "refreshPage" })
      public void test2() {
  
      }
  </code></pre>
  
  <p>And the @AfterMethod is run after both of them, even if only the second one is part of that group. I guess it doesn't relate to the Template testng.xml configuration file that is generated by eclipse for the execution. It's just a barebone setting for either the entire test class or individual test method. So it shouldn't influence groupings</p>
  
  <p>EDITED:</p>
  
  <p>So that in order to have @AfterMethod run after some methods only and run the entire test class, I have to run it twice, having two groups of methods (with/without refreshing).</p>
  
  <pre><code>&lt;test name="Test1"&gt;
    &lt;groups&gt;
      &lt;run&gt;
        &lt;include name="refreshPage*"/&gt;
      &lt;/run&gt;
    &lt;/groups&gt;
  
    &lt;classes&gt;
      &lt;class name="example.Test"/&gt;
    &lt;/classes&gt;
  &lt;/test&gt;
  
  &lt;test name="Test2"&gt;
    &lt;groups&gt;
      &lt;run&gt;
        &lt;include name="dontRefreshPage*"/&gt;
      &lt;/run&gt;
    &lt;/groups&gt;
  
    &lt;classes&gt;
      &lt;class name="example.Test"/&gt;
    &lt;/classes&gt;
  &lt;/test&gt;
  </code></pre>
  
  <p>I have no idea how to make it work when started via Eclipse, cause the <code>&lt;test&gt;</code> are replaced in the Template.</p>