如果我没记错的话,junit 5允许创建自定义方法订购器,以便可以自定义测试方法的顺序,但是我找不到与此相等的东西,似乎有一些方法可以在字母内订购测试订购或使用JVM订购等。但没有任何允许自定义执行的。这可能吗?
注意:我知道固定测试顺序是一种不好的做法,但是我正在研究这一点,而不是软件开发。
If I am not mistaken, Junit 5 allows creation of custom method orderers so that the order in which test methods are executed can be custom but I could not find something equivalent to this in Junit 4, there seems to be ways to order tests in alphabetical order or using JVM ordering etc. but nothing that allows for custom execution. Is this something possible?
note: I am aware of the fact that fixing test order is a bad practice however I am looking into this for research, not software development.
发布评论
评论(1)
从Junit 4.11开始,我们有注释
@fixmethodorder
和methodsorters.class
支持设置测试执行订单的设施。软件包
org.junit.runners。*
需要导入以包括类methodsorters
。该课程决定如何订购测试用例。Methodsorter
具有三个枚举值。请看一下 junit测试执行订单:测试命令:junit 4 vs junit 5 <以获取详细信息。
Starting JUnit 4.11, we have the annotation
@FixMethodOrder
andMethodSorters.class
supporting the facility of setting an order for a test’s execution.The package
org.junit.runners.*
needs to be imported to include the classMethodSorters
. This class decides how the test cases need to be ordered.MethodSorters
have three enum values.Please take a look at JUnit Test Execution Order: Order Of Tests JUnit 4 Vs JUnit 5 for details.