SpringBoot @FixMethodOrder 如何調(diào)整單元測試順序
SpringBoot @FixMethodOrder 調(diào)整單元測試順序
@RunWith(SpringRunner.class) @SpringBootTest @FixMethodOrder(MethodSorters.JVM) @Ignore public class ReviewServiceTest { @Autowired ReviewService reviewService; }
- MethodSorters.JVM
Leaves the test methods in the order returned by the JVM. Note that the order from the JVM may vary from run to run (按照JVM得到的方法順序,也就是代碼中定義的方法順序)
- MethodSorters.DEFAULT(默認的順序)
Sorts the test methods in a deterministic, but not predictable, order() (以確定但不可預(yù)期的順序執(zhí)行)
- MethodSorters.NAME_ASCENDING
Sorts the test methods by the method name, in lexicographic order, with Method.toString() used as a tiebreaker (按方法名字母順序執(zhí)行)
如果不生效, 應(yīng)該就是Junit版本問題, 注意這一點
SpringBoot Bean加載順序 Order無效
@Bean @Order(1) public xxx1 createXxx1() { return new xxx1(); } @Bean @Order(2) public xxx2 createXxx2() { return new xxx2(); }
經(jīng)過測試 ,并不起作用。
目前經(jīng)過測試、Order注解只有對aop的攔截順序有效
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
解決idea 通過build project 手動觸發(fā)熱部署失敗的問題
在debug運行項目的過程中,并且保證(不添加方法,不修改方法名)一定的規(guī)則的情況下,可以通過build project 來手動熱部署項目,本文給大家介紹解決idea 通過build project 手動觸發(fā)熱部署失敗的問題,感興趣的朋友一起看看吧2023-12-12IDEA創(chuàng)建Maven工程Servlet的詳細教程
這篇文章主要介紹了IDEA創(chuàng)建Maven工程Servlet的詳細教程,本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-10-10Java編程實現(xiàn)中英混合字符串?dāng)?shù)組按首字母排序的方法
這篇文章主要介紹了Java編程實現(xiàn)中英混合字符串?dāng)?shù)組按首字母排序的方法,涉及Java字符串操作及拼音轉(zhuǎn)換的相關(guān)使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-11-11