Junit 4.11 comes with
@FixMethodOrder
annotation. Instead of using custom solutions just upgrade your junit version and annotate test class with FixMethodOrder(MethodSorters.NAME_ASCENDING)
. Check the release notes for the details.
Here is a sample:
import org.junit.runners.MethodSorters;
import org.junit.FixMethodOrder;
import org.junit.Test;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SampleTest {
@Test
public void firstTest() {
System.out.println("first");
}
@Test
public void secondTest() {
System.out.println("second");
}
}
0 ความคิดเห็น:
แสดงความคิดเห็น