Issue
I have two individual test classes ( for example : TestClassA, TestClassB) I want TestClassA to run first and TestClassB to run next. How can i do so. Any ideas.
Note that i am using Springboot here and my test dependency is : spring-boot-starter-test
Solution
you can do using junit 5
@Test
@Order(1)
public void firstTest() {
output.append("a");
}
@Test
@Order(2)
public void secondTest() {
output.append("b");
}
check refence here https://www.baeldung.com/junit-5-test-order
and for different classes use test suite
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ TestClass1.class, TestClass2.class })
public class AllTests {
}
Answered By - JustTry