Reputation: 7
How to call a method from one test case by using Katalon Studio?
For example, I have a test case Purchase order and I have two test methods(test method1 and test method2 in it, Now what I want to do is, I want to create a new test case and call only test method2 in it.
Please suggest
Upvotes: 1
Views: 2277
Reputation: 3886
If that method2
consist purely of actions on one page, you could implement page object model:
package com.yourEntityName.pages;
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject;
import com.kms.katalon.core.exception.StepFailedException;
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI;
public class YourPage {
public void method2() throws StepFailedException {
// ...implementation goes here...
}
}
and just call it from the two test cases:
new YourPage().method2();
NOTE: a couple things about this:
KeywordUtil.logInfo()
the important stepsUpvotes: 0
Reputation: 5681
You can simply call an existing test case from a test case with this code:
WebUI.callTestCase(findTestCase({Test Case ID}), [key1:value1, key2:value2, … , keyN:valueN], FailureHandling.option)
A quick example:
WebUI.callTestCase(findTestCase('TestCaseToCall'), [:], FailureHandling.STOP_ON_FAILURE)
Upvotes: 2