Does JUnit 5 support test method execution in alphabetical order or any similar functionality? [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-06 10:56:22

JUnit issue is still open https://github.com/junit-team/junit5/issues/13 So, right now there is no such possibility.

Finally, this is now possible.
@TestMethodOrder is avaliable at snapshot version. (5.4)

@TestMethodOrder(OrderAnnotation.class)
class OrderedTestsDemo {

    @Test
    @Order(1)
    void nullValues() {
        // perform assertions against null values
    }

    @Test
    @Order(2)
    void emptyValues() {
        // perform assertions against empty values
    }

    @Test
    @Order(3)
    void validValues() {
        // perform assertions against valid values
    }

}

source: doc and commit

I know I'm late but JUnit5 is capable of that.

import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.TestMethodOrder;

@TestMethodOrder(MethodOrderer.Alphanumeric.class)
public class TestClass{
   //..
}

This Annotation is sorting by the actual method name, not the Displayname.

Unfortunately at the moment there is currently no mechanism in JUnit5 for ordering the execution of tests.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!