My question is about how to run in JUnit 5 test classes in parallel.
For example I have two simple test classes which represent two separated test pipeline and they should to run parallel. However the inner tests in class should run sequentially.
public class TestClass1 {
@Test
public void test1() {
System.out.println("Executing test 1 in Class 1");
System.out.println(Thread.currentThread().getId());
try {
Thread.sleep(5000);
Assert.assertTrue(false,"Assertion error in Test 1 Class 1");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Test
public void test2() {
System.out.println("Executing test 2 in Class 1");
Assert.assertTrue(false,"Assertion error in Test 2 Class 1");
System.out.println(Thread.currentThread().getId());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public class TestClass2 {
@Test
public void test2() {
System.out.println("Executing test 1 in Class 2");
System.out.println(Thread.currentThread().getId());
Assert.assertTrue(false,"Assertion error in Class 2");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}