JUnit4 有 @FixMethodOrder
注释,允许使用测试方法执行的字母顺序。是否有类似的 JUnit5 机制?
最佳答案
编辑:JUnit 5.4现已正式发布,因此不再需要使用快照。
现在 JUnit 5.4 可以实现这一点。
https://junit.org/junit5/docs/current/user-guide/#writing-tests-test-execution-order
To control the order in which test methods are executed, annotate your test class or test interface with @TestMethodOrder and specify the desired MethodOrderer implementation. You can implement your own custom MethodOrderer or use one of the following built-in MethodOrderer implementations.
Alphanumeric: sorts test methods alphanumerically based on their names and formal parameter lists.
OrderAnnotation: sorts test methods numerically based on values specified via the @Order annotation.
关于junit5 - 如何更改 JUnit5 中的测试执行顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40665216/