title: TestNG - @BeforeMethod for specific methods
body: <p>I'm using Spring Test with TestNG to test our DAOs, and I wanted to run a specific text fixture script before certain methods, allowing the modifications to be rolled back after every method so that the tests are free to do anything with the fixture data.</p>
  
  <p>Initially I thought that 'groups' would be fit for it, but I already realized they're not intended for that (see this question: <a href="https://stackoverflow.com/questions/7939892/testng-beforemethod-with-groups">TestNG BeforeMethod with groups</a> ).</p>
  
  <p>Is there any way to configure a <code>@BeforeMethod</code> method to run only before specific <code>@Test</code>s? The only ways I see are workarounds:</p>
  
  <ul>
  <li>Define an ordinary setup method and call at the beginning of every <code>@Test</code> method;</li>
  <li>Move the <code>@BeforeMethod</code> method to a new class (top level or inner class), along with all methods that depend on it.</li>
  </ul>
  
  <p>Neither is ideal, I'd like to keep my tests naturally grouped and clean, not split due to lack of alternatives.</p>