Iterating Test Cases that calls multiple test cases

Hi,
I need some help with the below scenario.
I have 10 different test cases that has the end-to-end flow. Each test case fetches data from different excel sheet page. I am calling all the 10 test cases in one test case (main).
Now I want to iterate the main test case that calls all the 10 test cases so the flow doesn’t break.

When i try to give a for loop in the main test case, the test case fails
for(int i = 0; i < 10; i++) {
WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Account -TC’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Contact’), [:], FailureHandling.STOP_ON_FAILURE)
}

When I try to give the same for loop in each individual 10 test cases, each test case repeats itself multiple times. Please help me get a solution for this.

Also in the test step on 1st test case (Account - TC ), do I need to update row to “i” instead of 1 if I give for loop in main test case ?

Eg:
WebUI.setText(findTestObject(‘Account/Account Edit Page/Account Name’), excelData.getValue(‘Account Name’, 1))

... findTestCase('Test Cases/TestCase Division/Account -TC') ...
... 
... findTestCase('Test Cases/TestCase Division/Contact') ...
....

This code implies that you have only 2 test cases except the main. But you wrote you have 10. The code may be wrong.

Could you list the names of these 10 test cases?

Yes @kazurayam… I do have 10 testcases called in the main test case, as n example i posted 2 earlier… The code runs successfully for the first row when i don’t give the for loop. The actual code in the main testcase is as below.

for(int i = 0; i < 10; i++) {

WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Account -TC’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Contact’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Add Contact on Account- TC’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Opportunity Creation - TC’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Add Product - TC’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Opportunity Won - TC’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Group Order - TC’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Group Product - TC’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Producer Commission - TC’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‘Test Cases/TestCase Division/Classes - TC’), [:], FailureHandling.STOP_ON_FAILURE)

}

The main test case is going to execute 10 test cases 10 times <- 100 test case executions in total.

What fails?

That sounds right. If you don’t want “each individual” test to repeat, don’t add a loop.

@Russ_Thomas These are the test steps in two of the test case. Because I have given the row value as 1, the values in 1st row executes successfully.

What changed do i need to make on main testcase and below 2 testcases to execute all rows in excel sheet?

"Account - TC"

WebUI.click(findTestObject(‘Object Repository/Account HomePage/Accounts’))

WebUI.click(findTestObject(‘Object Repository/Account HomePage/New Account Button’))

WebUI.selectOptionByValue(findTestObject(‘Object Repository/Account HomePage/Account Record Type’), ‘01230000000DUbR’, true)

WebUI.click(findTestObject(‘Object Repository/Account HomePage/Continue Button’))

WebUI.delay(3)

WebUI.setText(findTestObject(‘Account/Account Edit Page/Account Name’), excelData.getValue(‘Account Name’, 1))

WebUI.selectOptionByValue(findTestObject(‘Account/Account Edit Page/Type_account’), excelData.getValue(‘Type’, 1), true)

"Contact"
WebUI.click(findTestObject(‘Object Repository/Contact/New Contact Button/Related Contacts0’))

WebUI.click(findTestObject(‘Object Repository/Contact/New Contact Button/New Contact Button’))

WebUI.selectOptionByValue(findTestObject(‘Contact/Contact Record Type/Contact Record Type’), ‘01230000000XgOL’, true)

WebUI.click(findTestObject(‘Contact/Contact Record Type/Continue Button_Contact’))

WebUI.setText(findTestObject(‘Contact/Contact Edit Page/First Name’), excelData.getValue(
1, 1))

WebUI.setText(findTestObject(‘Contact/Contact Edit Page/Last Name’), excelData.getValue(
2, 1))

WebUI.setText(findTestObject(‘Contact/Contact Edit Page/Contact Phone Extension’), excelData.getValue(
3, 1))

I don’t use Excel or Katalon’s DDT stuff. I think this should help:

I am not sure what you want to achieve. I guess you want to pass the value of iteration (0,1,2,3,…,9) from the caller to the callee test cases. You can do it as follows.

In your main test case,

for (int i = 0; i < 10; i++) {
    WebUI.callTestCase(
        findTestCase(‘Test Cases/TestCase Division/Account -TC’),
                     ['index': i],           // pass the value of index here
                     FailureHandling.STOP_ON_FAILURE)
    ...

In Account-TC

...
WebUI.setText(findTestObject(‘Account/Account Edit Page/Account Name’), 
    excelData.getValue(‘Account Name’, index))      // the value of 'index' is parameterized
...

You would need to mind about the index value to be 0-based or 1-based.

1 Like

@kazurayam Yes that’s exactly what i wanted. Your code worked for me. Thank you very much.