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

网友投稿 735 2022-12-11

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

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

目录SpringBoot @FixMethodOrder 调整单元测试顺序SpringBoot Bean加载顺序 Order无效

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加载顺序http:// Order无效

@Bean

@Order(1)

public xxx1 createXxx1() {

return new xxx1();

}

@Bean

@Order(2)

public xxx2 createXxx2()http:// {

return new xxx2();

}

经过测试 ,并不起作用。

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

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Spring security 如何开放 Swagger 访问权限
下一篇:JUnit测试控制@Test执行顺序的三种方式小结
相关文章

 发表评论

暂时没有评论,来抢沙发吧~