gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 19:11:37 27 4
gpt4 key购买 nike

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com