[英]Order of execution in junit
My code我的代码
import org.junit.Test;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.TestMethodOrder;
@TestMethodOrder(OrderAnnotation.class)
public class Order {
@Test
@Order(4)
public void test1() {
System.out.println("This is test 1");
}
@Test
@Order(3)
public void test2() {
System.out.println("This is test 2");
}
@Test
@Order(2)
public void test3() {
System.out.println("This is test 3");
}
@Test
@Order(1)
public void test4() {
System.out.println("This is test 4");
}
}
The output of the code output的代码
This is test 1
This is test 2
This is test 3
This is test 4
Does anyone know what is wrong with the code?有谁知道代码有什么问题? I need to execute it in the order that I provided.我需要按照我提供的顺序执行它。
Change the first import - import org.junit.Test;
改变第一个import org.junit.Test;
to import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Test;
, that is the issue here. ,这就是这里的问题。 I've got output as:我有 output 为:
This is test 4
This is test 3
This is test 2
This is test 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.