如何对使用弹簧重试机制的方法进行单元测试

时间:2020-07-20 18:25:44

标签: spring junit mockito spring-test spring-retry

我正在尝试编写一个Junit方法,该方法使用spring重试机制来重新调用失败的操作。 但是我无法验证spring retry是否可以与JUnit一起正常工作。

targetFragment

1 个答案:

答案 0 :(得分:0)

@InjectMocks
StudentServiceImpl classUnderTest;

您将其作为Mock注入,而不是使用Spring @Autowired来获得带有重试拦截器的完整Spring代理。