Retry the steps when exception has occured

In order to improve stability, I hope I can try again every second when an exception occurs until out of the time I defined. How can I achieve it?

Hello,

the approach you describe is really not a good practice. You never know the state where exception is thrown and why it is thrown, so simply repeat the same method is bad. What you can do to improve stability and durability of your tests:

  • Write atomic tests, do not test more than a single functionality in a single test; this reduces a risk of false-negative results
  • Throw exceptions at keyword level and define what to do in case of failure
  • Use (explicit) waits
  • When a test fails, repeat whole test
  • And the most important, try to write such tests, which are able to run deterministic, no matter how slow AUT or network is
1 Like

Hi Marek_Melocik:
Thank you for your advice.
I’ll optimize the testcase structure and method.