Forum Discussion
Well, see, it's a loop... so it will CONSTANTLY repeat... I wouldn't use "while" at all... these are individual conditions...
I mean, there are MANY ways of achieve the same effect but it comes down to instructing TestComplete that a) the function failed and b) what to do when it fails. Returning "successful" is one such thing.
What I do is I have each step in my test case as an object in an array. I then iterate the array (using a "for" loop) and call the "execute" method on each step... if the method is successful, I continue... if it's not, I call "break" and break out of the loop and then clean up the test case.
So... that's another way of doing it... each one of your "functions" could represent an array item that you can then loop through the length of the array and break if unsuccesful. Proof of concept...
function test1() {
Log.Message('step 1');
return false
}
function test2() {
Log.Message('step 2');
return true;
}
function bar() {
var myArray = [];
myArray.push(test1);
myArray.push(test2);
for (var i = 0; i < myArray.length; i++) {
if (!myArray[i]()) break;
}
}
Running the bar function will result in my test log only showing that step 1 was run. If I change step 1 to return true, both functions execute.
I think I see what you're saying and how I can apply it to my current script. Thanks I will give this a try.