Forum Discussion

ANW's avatar
ANW
Contributor
14 years ago

Possible to restart a function on certain conditions?

I have a test where I create a new customer in my system. During creation I make a lookup to an official register of all people here in Denmark. I use the person's social security number to find name and address information.



however, once in a while, the person I am trying to look up is address protected, and thus I get an error. My problem is that I have no idea if the selected person (chosen randomly in our database at script start) is address protected or not.



Currently all I can do when that happens is stop the script and retry. 



but is there a way I can restart the whole script if I encounter this type of error? ... basically I just want my script to report a warning in my log, and then retry.



I am aware that I can somehow put a giant loop around the whole script, and then repeat until a customer gets through validation. But is that the best/only way of doing this?



I would then have to make this loop in every script where I create new customers.

1 Reply

  • Hello Anders,


    I recommend that you create a helper function and call this function from other tests. The function will have to use a loop to obtain a person whose account is not address protected. You can use project or project suite variables to exchange data about the person between different parts of your test.