# Calling test cases based on result

**URL:** <https://forum.katalon.com/t/calling-test-cases-based-on-result/89686>\
**Category:** Miscellaneous\
**Created:** [June 7, 2023, 5:31pm UTC](https://forum.katalon.com/t/calling-test-cases-based-on-result/89686 "2023-06-07T17:31:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh.meeks](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/josh.meeks/32/25928_2.png) [@josh.meeks](https://forum.katalon.com/u/josh.meeks)\
**Post date:** [June 7, 2023, 5:31pm UTC](https://forum.katalon.com/t/calling-test-cases-based-on-result/89686/1 "2023-06-07T17:31:29Z")

</div>

How does one execute the following:

def result1 == WebUI.callTestCase() whatever

if(result1 == ‘Passing’){  
WebUI.callTestCase()\_Whatever2  
}

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [June 7, 2023, 6:00pm UTC](https://forum.katalon.com/t/calling-test-cases-based-on-result/89686/2 "2023-06-07T18:00:09Z")

</div>

The method, callTestCase, has a return type of Object, so you might do something like:

```auto
def result1 = WebUI.callTestCase(findTestCase('TC1'), [:], FailureHandling.OPTIONAL)

if (result1.toString() == 'Passed') {
    WebUI.callTestCase(findTestCase('TC2_Whatever2'), [:], FailureHandling.OPTIONAL)
}

```

and inside TC1 return a String Object, like

```auto
...
if (condition) {
    return 'Passed'
} else {
   return 'Failed'
}

```

Another method that I have used was to use GlobalVariables of a Map, or a List depending on need to pass between the called Test Case and the running one.

```auto
GlobalVariable.gTempHolder = [];

WebUI.callTestCase(findTestCase('TC1'), [:], FailureHandling.OPTIONAL)

for (int i = 0; i < (GlobalVariable.gTempHolder as List).size(); i++) {
	WebUI.comment('values are ' + GlobalVariable.gTempHolder[i].toString())
}

```

and inside the test case, ensure you have:

```auto
import internal.GlobalVariable as GlobalVariable

```

---

<div class="post-metadata">

**Author:** ![josh.meeks](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/josh.meeks/32/25928_2.png) [@josh.meeks](https://forum.katalon.com/u/josh.meeks)\
**Post date:** [June 7, 2023, 7:26pm UTC](https://forum.katalon.com/t/calling-test-cases-based-on-result/89686/3 "2023-06-07T19:26:50Z")

</div>

Thank you ! I thought that maybe thats what I was missing I just didnt know where I needed it to go!
