Forum Discussion
Colin_McCrae
11 years agoCommunity Hero
Which is fine.
But I would add a timeout as a second way to exit that loop.
Any loop which has the potential to get stuck in a never ending cycle is not a good idea with automated tests as it'll just sit there forever if the value you expect is not populated to the available list.
So:
While([object is not in list] AND [time waited < 10 seconds])
Look for object in list
Short delay if not found
End While
... would be a more sensible way to go I think.
Obviously, you would then need some branching after the loop to determine what should happen next depending on whether the value was found or not.
I have plenty such functions in my code. My stuff has to run unattended. Often for hours at a time. So getting stuck in a never ending loop would not be good.
But I would add a timeout as a second way to exit that loop.
Any loop which has the potential to get stuck in a never ending cycle is not a good idea with automated tests as it'll just sit there forever if the value you expect is not populated to the available list.
So:
While([object is not in list] AND [time waited < 10 seconds])
Look for object in list
Short delay if not found
End While
... would be a more sensible way to go I think.
Obviously, you would then need some branching after the loop to determine what should happen next depending on whether the value was found or not.
I have plenty such functions in my code. My stuff has to run unattended. Often for hours at a time. So getting stuck in a never ending loop would not be good.