Example Test:
@Test
public void shouldGetRoutesList() {
Response response =
given()
.headers("RequestId", 10)
.headers("Authorization", accessToken)
.contentType(ContentType.JSON).
expect()
.statusCode(HttpURLConnection.HTTP_OK).
when()
.get("address");
String responseBody = response.getBody().asString();
System.out.println(responseBody);
logger.info("Log message");
}
Thing is that sometimes response from service equals 500 error. It's because of application error and it's application fault so I would like to add temp. workaround to retry .get
if service returns 500. I was thinking about if
or do-while
but I know that it's not very clever way. Anyone could advice some solution ?
In another words - I want to retry whole test (or just .get) if statusCode=!HTTP_OK