How to run test methods in specific order in JUnit4?

后端 未结 18 1842
伪装坚强ぢ
伪装坚强ぢ 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 05:04

    you can use one of these piece of codes:

    @FixMethodOrder(MethodSorters.JVM)OR `@FixMethodOrder(MethodSorters.DEFAULT)` OR `@FixMethodOrder(MethodSorters.NAME_ASCENDING)` before your test class like this:
    
    
    @FixMethodOrder(MethodSorters.NAME_ASCENDING)
    
    
    public class BookTest { ...}
    

提交回复
热议问题