title: How to write script in gradle that execute particular methods?
body: <p>I am writing a gradle script that runs all tests before making a build. </p>
  
  <pre><code>test {
      filter {
          includeTestsMatching "*TestAll*"
          includeTestsMatching "*ExtensionValidatorTest*"
          ........
      }
  }
  </code></pre>
  
  <p>I have three tests of different versions(v1,v2,v3).</p>
  
  <p><strong>TestAll.java</strong></p>
  
  <pre><code>package .....v1;//v2 for version 2 and v3 for version 3
  
  @RunWith(Suite.class)
  @Suite.SuiteClasses({
        A.class,
        B.class,
        ......
  })
  public class TestAll {
  
      @BeforeClass
      public static void setUp() {//connection to database
           ........
      }
  
      @AfterClass
      public static void tearDown()  {//close database connection 
           ........
      }
  }
  </code></pre>
  
  <p>When I run <code>gradle test</code> connection to database is broken after execution of a particular TestAll. I do not want to change the TestAll files of any version as they can be run and tested independently. How can I make gradle run only setUp once(of any version)which establishes connection, then run all the TestAll method in v1,v2 and v3 and finally teardown(of any version) which terminates database connection. </p>