JUNIT 4中的MethodOrder等同于为测试执行创建自定义订单是什么?

发布于 2025-02-03 05:30:26 字数 179 浏览 4 评论 0 原文

如果我没记错的话,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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤凫 2025-02-10 05:30:26

从Junit 4.11开始,我们有注释 @fixmethodorder methodsorters.class 支持设置测试执行订单的设施。

软件包 org.junit.runners。*需要导入以包括类 methodsorters 。该课程决定如何订购测试用例。 Methodsorter 具有三个枚举值。

MethodSorters.DEFAULT
MethodSorters.JVM
MethodSorters.NAME_ASCENDING

请看一下 junit测试执行订单:测试命令:junit 4 vs junit 5 <以获取详细信息。

Starting JUnit 4.11, we have the annotation @FixMethodOrder and MethodSorters.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 class MethodSorters. This class decides how the test cases need to be ordered. MethodSorters have three enum values.

MethodSorters.DEFAULT
MethodSorters.JVM
MethodSorters.NAME_ASCENDING

Please take a look at JUnit Test Execution Order: Order Of Tests JUnit 4 Vs JUnit 5 for details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文