How to run test methods in specific order in JUnit4?

后端 未结 18 2118
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 04:35

I want to execute test methods which are annotated by @Test in specific order.

For example:

public class MyTest {
    @Test public void          


        
18条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 04:53

    See my solution here: "Junit and java 7."

    In this article I describe how to run junit tests in order - "just as in your source code". Tests will be run, in order as your test methods appears in class file.

    http://intellijava.blogspot.com/2012/05/junit-and-java-7.html

    But as Pascal Thivent said, this is not a good practise.

提交回复
热议问题