SpringBoot @FixMethodOrder单元测试顺序 SpringBoot @FixMethodOrder 怎样调整单元测试顺序

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

SpringBoot @FixMethodOrder单元测试顺序 SpringBoot @FixMethodOrder 怎样调整单元测试顺序

李昊轩的博客   2021-09-06 我要评论
想了解SpringBoot @FixMethodOrder 怎样调整单元测试顺序的相关内容吗,李昊轩的博客在本文为您仔细讲解SpringBoot @FixMethodOrder单元测试顺序的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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的拦截顺序有效

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

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们