CallTestCase in CustomKeyword

Can we call testcase in CustomKeyword?

If yes, please tell me how. Thanks.

Yes, Katalon have. You can find out at:[Common]+Call+Test+Case

The above link is for Calling Testcase in another testcase. But i want calltestcase inside custom keyword

I made a Test Case named “CalleeTestCase” as follows:

return "Hello, ${name}"

I made a Custom Keyword named “mypack.CallerInKeywords” as follows

package mypackimport static com.kms.katalon.core.testcase.TestCaseFactory.findTestCaseimport com.kms.katalon.core.annotation.Keywordimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIclass CallerInKeywords {    @Keyword    def callATestCase() {        def greeting = WebUI.callTestCase(findTestCase('CalleeTestCase'), ["name": "Nikolai"])        WebUI.comment("*** ${greeting}")    }}

And I made a Test Case named “CallerTestCase” as follows:

import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCaseimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI// call a Test Casedef greeting = WebUI.callTestCase(findTestCase('CalleeTestCase'), ["name": "Sergei"])WebUI.comment(">>> ${greeting}")// call the same Test Case indirectly via a Custom KeywordCustomKeywords.'mypack.CallerInKeywords.callATestCase'()

I executed the “CallerTestCase” and got the following output:

...08-27-2018 10:14:54 PM - [INFO]   - >>> Hello, Sergei...08-27-2018 10:14:54 PM - [INFO]   - *** Hello, Nikolai...

This proves that we can call a Test Case within Keyword.

I am afraid that this example is not very interesting.


Thank you