How to test Spring Boot @Retryable in cucumber?

76 views Asked by At

How do I write integration test for Spring Boot @Retryable in cucumber? I have a service method annotated with @Retryable. MaxAttempt is set to 3 and delay is 1. To mock the server, I am going to use wiremock.

I want to assert that the retry function is working correctly; meaning I want to write test scenario when the certain exception is thrown, the retry will be happened. and if it fails all the time then it will throw exception eventually else if it's successful during the retrials, then it should assert that the http status code is 200 OK.

I want to assert that retry is triggered for 3 times as its max attempt is set to 3 and http status code and maybe thrown exception? I've thought about some ideas to do this.. First one is to have RetryableContext class which have int retryCount varible. And each time retry is invoked then increase its value. --> honestly I don't think it's good idea.. Second one is to leverage spring AOP..? Not not really sure how to actually achieve it. I mean I am not confident with coding it out with this approach.

0

There are 0 answers