微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法在 Springboot 单元测试中获取弹性 4j 重试注释以执行

如何解决无法在 Springboot 单元测试中获取弹性 4j 重试注释以执行

我正在尝试编写单元测试以使用 @retry 注释验证我的弹性 4j 应用程序,但它根本没有重试。代码在我运行时有效,只是无法对其进行单元测试.. 有什么想法吗?

@ExtendWith(SpringExtension.class)
@SpringBoottest(classes = {ClassImTesting.class})
public class MyCoolTest {

    @Autowired
    private MyClass thing;


    @Test
    public void mytest() throws TransformationException {
        thing.transform(null);
    }

ClassImTesting

  @Override
  @Retry(name = "transformer",fallbackMethod = "handleFailure")
  public void transform(Thing record)
      throws TransformationException {
    return this.transform(record.value());
  }

public void handleFailure(Thing record,Throwable t) {
   // stuff
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。