[英]Junit 5 order tests with @Tag from some classes
I have some classes.我有一些课。 I all classes, I have some tests.
我所有的类,我有一些测试。 Example:
例子:
public class testpage1(){
@test
@Tag("Regression")
void test1(){
system.out.println("Test1");
}
void test2(){
system.out.println("Test2");
}
}
public class testpage2(){
@test
@Tag("Regression")
void test3(){
system.out.println("Test3");
}
void test4(){
system.out.println("Test4");
}
}
public class testpage3(){
@test
@Tag("Regression")
void test5(){
system.out.println("Test5");
}
void test6(){
system.out.println("Test6");
}
}
I have other class to run:我还有其他 class 要运行:
@RunWith(value = JunitPlatform.class)
@IncludeTags(value = {"Regression"})
When I run this class, The test run without any order,当我运行这个 class 时,测试运行没有任何顺序,
How can I order the test to run in order that I want?我怎样才能命令测试按我想要的顺序运行?
with Junit normally the test methods will be executed in the order of their names, sorted in ascending order.对于 Junit,通常测试方法将按其名称的顺序执行,按升序排序。
or you can specify an order using annotation @Order @Order(1) @Order(2)...或者您可以使用注解 @Order @Order(1) @Order(2) 指定订单...
jUnit5 allows you to set the tests execution order with @Order()
annotation. jUnit5 允许您使用
@Order()
注释设置测试执行顺序。
So, you can add these annotations in your code as following:因此,您可以在代码中添加这些注释,如下所示:
public class testpage1(){
@test
@Order(1)
@Tag("Regression")
void test1(){
system.out.println("Test1");
}
void test2(){
system.out.println("Test2");
}
}
public class testpage2(){
@test
@Order(2)
@Tag("Regression")
void test3(){
system.out.println("Test3");
}
void test4(){
system.out.println("Test4");
}
}
public class testpage3(){
@test
@Order(3)
@Tag("Regression")
void test5(){
system.out.println("Test5");
}
void test6(){
system.out.println("Test6");
}
}
This should make these tests executed correspondingly这应该使这些测试相应地执行
Thank, I have all the page @order for all the tests, per test, I forgot to note it at the first.谢谢,我有所有测试的所有页面@order,每次测试,我一开始都忘了记下它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.