服务器之家

服务器之家 > 正文

SpringBoot @FixMethodOrder 如何调整单元测试顺序

时间:2021-12-21 13:23     来源/作者:李昊轩的博客

SpringBoot @FixMethodOrder 调整单元测试顺序

?
1
2
3
4
5
6
7
8
@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无效

?
1
2
3
4
5
6
7
8
9
10
@Bean
@Order(1)
public xxx1 createXxx1() {
    return new xxx1();
}
@Bean
@Order(2)
public xxx2 createXxx2() {
    return new xxx2();
}

经过测试 ,并不起作用。

目前经过测试、Order注解只有对aop的拦截顺序有效

以上为个人经验,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://haoxuanli.blog.csdn.net/article/details/105195935

相关文章

热门资讯

2022年最旺的微信头像大全 微信头像2022年最新版图片
2022年最旺的微信头像大全 微信头像2022年最新版图片 2022-01-10
蜘蛛侠3英雄无归3正片免费播放 蜘蛛侠3在线观看免费高清完整
蜘蛛侠3英雄无归3正片免费播放 蜘蛛侠3在线观看免费高清完整 2021-08-24
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
yue是什么意思 网络流行语yue了是什么梗
yue是什么意思 网络流行语yue了是什么梗 2020-10-11
暖暖日本高清免费中文 暖暖在线观看免费完整版韩国
暖暖日本高清免费中文 暖暖在线观看免费完整版韩国 2021-05-08
返回顶部