SpringBoot @FixMethodOrder 如何调整单元测试顺序
SpringBoot @FixMethodOrder 调整单元测试顺序
@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() (以确定但不可预期的顺序执行)
- MethodSorters.NAME_ASCENDING
Sorts the test methods by the method name, in lexicographic order, with Method.toString() used as a tiebreaker (按方法名字母顺序执行)
如果不生效, 应该就是Junit版本问题, 注意这一点
SpringBoot Bean加载顺序 Order无效
@Bean
@Order(1)
public xxx1 createXxx1() {
return new xxx1();
}
@Bean
@Order(2)
public xxx2 createXxx2() {
return new xxx2();
}
经过测试 ,并不起作用。
目前经过测试、Order注解只有对aop的拦截顺序有效
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
spring+mybatis 通过@ResponseBody返回结果中文乱码的解决方法
下面小编就为大家分享一篇spring+mybatis 通过@ResponseBody返回结果中文乱码的解决方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2017-12-12
Java Serializable和Parcelable详解及实例代码
这篇文章主要介绍了Java Serializable和Parcelable详解,并附实例代码的相关资料,需要的朋友可以参考下2016-09-09
使用spring security明文密码校验时报错-BadCredentialsException:&nbs
小编遇到这样一个问题在学习spring security时使用明文密码进行登录校验时报错"org.springframework.security.authentication.BadCredentialsException: Bad credentials,今天给大家分享问题原因及解决方案,感兴趣的朋友一起看看吧2023-10-10


最新评论