Forum Discussion

cbaquero's avatar
cbaquero
New Contributor
12 years ago

Retry Test Step or entire Test Case on specific HTTP Reponse

Hi all,
I'm testing REST services with SoapUI and have lead into something that I don't know how to solve.

The application I'm testing has an authentication REST service that returns a token for a user+pass set. I have a specific "Get Token" test case in the Test Suite that runs before the rest of the Test Cases and saves the token for the suite so the other test cases can use it.

The thing is that the token expires every 10 minutes, and I can only use the "Get Token" Test Case to get a new one after it has expired (before that, it returns the same token). So, in every REST Request Step I need to check if the HTTP Response is a 401 (non authorized) error, if it is then I should get a new token.

What I find a really bad practice is to add a "Conditional Go To" step after every existing "REST Request" step, so I was wondering if it would be a better way to:
1- Run a REST Request Step
2- If reponse is a 401 HTTP Error
2.a Get a new Token
2.b- Re-try the Request (1)

I'll appreciate any comments or ideas.
Thanks in advance!
Carolina.-