Katalon, 5.4, Test Case with for loop will not exit Test Case

After I installed Katalon 5.4, I created a test suite which calls three different test cases. The middle of the three test cases uses Excel data and contains a for loop. Even though all the conditions of the for loop are met (the loop exits properly), when the script gets to the bottom of the test case it starts the test case over again. Katalon never reaches the third test case. I have another project which also uses Excel data and also has a loop, but is run as a single test case (not called from a test suite). It works properly. Has anyone experienced this or can anyone replicate this behavior?

I have done some more investigating. Currently, I have it setup like this:
Test Suite
Test Case ‘EP-3715’ loops through records in Excel data
Calls ‘Delete Person’ Test Case for each record
Test Case ‘EP-3715’ ends
Test Case 'EP-3715 starts over again (!!!)
Other test cases are never run

Here is the log file where I put in println to see what was going on:
04-27-2018 08:48:59 AM - [START] - Start action : Statement - println(“end of EP-3715”)
end of EP-3715
04-27-2018 08:49:05 AM - [END] - End action : Statement - println(“end of EP-3715”)
04-27-2018 08:49:05 AM - [PASSED] - Test Cases/EMBR Core/EP-3715
04-27-2018 08:49:05 AM - [END] - End Test Case : Test Cases/EMBR Core/EP-3715
04-27-2018 08:49:05 AM - [START] - Start Test Case : Test Cases/EMBR Core/EP-3715

The code for that EP-3715 test case is:
println (‘beginning of EP-3715’)

’ load the test data ’
ExcelData data = findTestData(‘People’)

int totalRows = data.getRowNumbers()
println ('Total rows = ’ + totalRows)

’ Delete n number of people ’
delPeople: for (int index = 0; index <= data.getRowNumbers(); index++) {
println ('index = ’ + index)

' goto home page '  
WebUI.navigateToUrl(GlobalVariable.URL, FailureHandling.STOP\_ON\_FAILURE)  
WebUI.waitForPageLoad(GlobalVariable.timeout)  
 
' pass last\_name and first\_name of the person card to Delete Person test'  
WebUI.callTestCase(findTestCase('EMBR Core/Delete Person'), \[('first\_name') : data.internallyGetValue('first\_name', index), ('last\_name') : data.internallyGetValue('last\_name', index), ('permanentlyDelete') : true\],  
    FailureHandling.STOP\_ON\_FAILURE)  
 
if (index == totalRows){  
    break delPeople  
}  

}
println (‘end of EP-3715’)

Anybody have any insights? What am I missing? Thanks!

I could be way off here – maybe I’m misreading it but… why are you doing:

break delPeople

A FOR loop using a fixed number of iterations does not need a break statement.

Also, if you know the length of the loop in totalRows, why don’t you use it in the FOR loop condition?

for(int index = 0; index <= totalRows; ...

Further, if getRowNumbers returns the number of rows (e.g. 6) then your index is off by one if you use index = 0 and <=

HTH

Russ,

First thank you for taking the time to reply. All your points are valid and correct. The things you pointed out are tweaks I was making, changing and experimenting with trying to find out if the problem was the for loop not exiting properly or the test case repeating itself for some reason. I will go back and clean up the code.

What I am really interested in learning is why does my test case repeat itself? It should move on to the next test case in the Test Suite should it not?

Well, it’s not clear to me what is going on…

Did you try moving the TC to first in the list? (Maybe functionally that makes no sense?)

How about introducing a very simple TC with a for loop that does essentially nothing, place it in a suite prior to another TC… What happens? If that guy repeats, then you have a simplistic STR to report as a bug. If, however, it does not, the culprit is in your TC(s) somewhere… right?

Good ideas. Yes, I tried my TC as the first in the list. Right now, aside from the Login and Logout test cases, it is the only other TC in the Suite. I will try the simple for loop TC you suggested…but after lunch. :slight_smile: Thanks for your guidance.

OK, the solution: Do not use the Test Suite’s test data and variable binding in the Katalon interface and the Test Cases will end properly (they will not infinitely repeat themselves).

If I use the Test Suite’s test data and variable binding interface to add the column names from my Excel spreadsheet as local variables of the same name and use “Map All” as the documentation shows, the Test case will repeat itself forever. Please note that in my situation I am calling a test case from within a test case and passing variables derived from an ExcelData object to the called test case.