问题描述
JUnit4具有@FixMethodOrder
批注,该批注允许使用按字母顺序排列的测试方法执行顺序.有类似的JUnit5机制吗?
JUnit4 has @FixMethodOrder
annotation which allows to use alphabetical order of test methods execution. Is there analogous JUnit5 mechanism?
推荐答案
JUnit 5.4现在正式发布,因此不再需要使用快照.
JUnit 5.4 is officially released now, so no need to use snapshots anymore.
现在可以通过JUnit 5.4实现.
This is now possible with JUnit 5.4.
https://junit.org /junit5/docs/current/user-guide/#writing-tests-test-execution-order
字母数字:根据测试方法的名称对它们进行字母数字排序 和正式的参数列表.
Alphanumeric: sorts test methods alphanumerically based on their names and formal parameter lists.
OrderAnnotation:根据值对测试方法进行数字排序 通过@Order注释指定.
OrderAnnotation: sorts test methods numerically based on values specified via the @Order annotation.
这篇关于如何在JUnit5中更改测试执行顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!