junit5 - 如何更改 JUnit5 中的测试执行顺序?

标签 junit5

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/

相关文章:

java - 测试 PBEKeySpec junit

java - 升级JUNIT 5后无单元测试

java - Testcontainers - 在实例化期间不要自动启动容器

java - 三个测试容器来自哪里?

java - 一个组件需要一个名为 'mongoTemplate' 的 bean,但在 JUnit 5 Controller Test 中找不到

unit-testing - Powermock 在使用 JUnit 5 时抛出 ClassNotPreparedException

eclipse - 无法在Jipster示例应用程序Gradle中运行Eclipse中的Junits

android - 无法使用 Gradle 6.1.1 解析 junit-jupiter-params :5. 6.2 和 junit-jupiter-engine :5. 6.2

gradle - 运行gradle测试时找不到嵌套Kotlin类中的JUnit测试

java - JUnit 5 TestSuite 替代方案?