title: TestNG dataproviders with a @BeforeClass
body: <p>I am trying to run a class with multiple tests under two different conditions. Basically I have a bunch of tests related to a search. I am adding new functionality of a new search strategy, and in the meantime want to run the already written tests under both configurations. As we have multiple classes each with multiple tests I want to streamline this process as much as possible. Ideally it'd be great to do the setup in a @BeforeClass with a data provider so that all tests in the class are basically run twice under the different configurations, but doesn't look like this is possible.</p>
  
  <p>Right now I have: </p>
  
  <pre><code>public class SearchTest1 {
      @Test(dataProvider = "SearchType")
      public void test1(SearchType searchType) {
          setSearchType(searchType);
          //Do the test1 logic
      }
  
      @Test(dataProvider = "SearchType")
      public void test2(SearchType searchType) {
          setSearchType(searchType);
          //Do the test2 logic
      }
  
      @DataProvider(name = "SearchType")
      public Object[][] createData() {
          return new Object[][]{
              new Object[] {SearchType.scheme1, SearchType.scheme2}
          }
      }
  }
  </code></pre>
  
  <p>Is there a better way to do this? </p>