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)文章
spring+mybatis 通過@ResponseBody返回結(jié)果中文亂碼的解決方法
下面小編就為大家分享一篇spring+mybatis 通過@ResponseBody返回結(jié)果中文亂碼的解決方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2017-12-12
java從命令行獲取數(shù)據(jù)的三種方式代碼實例
這篇文章主要介紹了java從命令行獲取數(shù)據(jù)的三種方式代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-12-12
Java Serializable和Parcelable詳解及實例代碼
這篇文章主要介紹了Java Serializable和Parcelable詳解,并附實例代碼的相關(guān)資料,需要的朋友可以參考下2016-09-09
使用spring security明文密碼校驗時報錯-BadCredentialsException:&nbs
小編遇到這樣一個問題在學(xué)習(xí)spring security時使用明文密碼進行登錄校驗時報錯"org.springframework.security.authentication.BadCredentialsException: Bad credentials,今天給大家分享問題原因及解決方案,感興趣的朋友一起看看吧2023-10-10
Java并發(fā)編程創(chuàng)建并運行線程的方法對比
這篇文章主要為大家詳細介紹了Java并發(fā)編程創(chuàng)建并運行線程的方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助2022-03-03

