如何在JUnit5中为测试套件设置自定义测试执行顺序? [英] How to set custom test execution order for a test suite in JUnit5?
问题描述
我在JUnit5上进行了大量测试,我在多个线程中并行运行. 还提供有关每次测试时间的信息. 我想在最长的测试开始时运行,而在最后的测试中保留最快的运行时间,以优化常见的执行时间.
I have a large set of tests on JUnit5, which I run in parallel in several threads. There is also information about the time of each test. I want to run at the beginning of the longest tests, and leave the fastest at the end to optimize common execution time.
我还没有在JUnit5中找到实现此目的的方法.
I have not found a way to do this in JUnit5.
在版本5.4
中,有一个org.junit.jupiter.api.MethodOrderer
接口,使您可以在测试类中编写测试分类器.并通过注释org.junit.jupiter.api.TestMethodOrder
连接到测试类.
In version 5.4
there is an org.junit.jupiter.api.MethodOrderer
interface which allows you to write a test sorter within a test class. And connect to the test class via the annotation org.junit.jupiter.api.TestMethodOrder
.
对于整个测试套件,我希望获得类似的结果,但在全球范围内.
I would like something similar, but globally, for the whole test suite.
推荐答案
不幸的是,您目前所要求的在JUnit 5中是不可能的(例如,在JUnit平台上或在JUnit Jupiter中).
What you're asking for is unfortunately not currently possible in JUnit 5 (i.e., either on the JUnit Platform or within JUnit Jupiter).
但是,有一个专门针对该主题的未解决问题.因此,请随时在其中鸣响.
There is however an open issue dedicated to this topic. So feel free to chime in there.
这篇关于如何在JUnit5中为测试套件设置自定义测试执行顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!