I am writing a gradle script that runs all tests before making a build.
test {
filter {
includeTestsMatching "*TestAll*"
includeTestsMatching "*ExtensionValidatorTest*"
........
}
}
I have three tests of different versions(v1,v2,v3).
TestAll.java
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
........
}
}
When I run gradle test
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.