I wanted to choose the order to execute the JUnit tests. I have 4 classes with several test methods in it, my goal is to execute, for instance, method Y of class A, then met
From version 4.11 you can specify execution order using annotations and ordering by method name:
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class MyTest {
@Test
public void test1Create() {
System.out.println("first");
}
@Test
public void test2Update() {
System.out.println("second");
}
}
See JUnit 4.11 Release Notes