When using this approach below, by setting up the jUnit with Suites. We got the problem when all @BeforeClass in every Testclass will be executed before any tests starts to execute. (For each n TestClass file the @BeforeClass runs, then after they have execute, it started to execute the first MyTest.class files @Test)
This will cause that we allocate up much resources and memory. My thoughts was that it must be wrong, shouldn't each @BeforeClass run only before the actual testclass is executed, not when the Suite is started?
@RunWith(Suite.class)
@Suite.SuiteClasses({ MyTests.class, Mytests2.class, n1, n2, n })
public class AllTests {
// empty
}
public class MyTests { // no extends here
@BeforeClass
public static void setUpOnce() throws InterruptedException {
...
@Test
...
public class MyTests2 { // no extends here
@BeforeClass
public static void setUpOnce() throws InterruptedException {
...
@Test
...