Test Cases return a result so it’s a shame you don’t want to use call. I guess you don’t want to have multiple cases inside another case?
Your other option is to set a GlobalVariable which you can examine before you execute the body of a test case. You will need to ensure the GV is set so you can run the TCs manually outside of a suite (if that matters to you).
Can you share with us why you don’t want to use Call Test Case. It seems like a solution to the problem you are stating, or there are some more context ?
Well some background about this use case… I am working in logistics domain.
We do scenario/ workflow based testing, and each testcase is around 600 steps.
So we have logically brokedown one scenario into 19 sub scenario based on the functionality.
And finally we used to call all these sub scenario in the one test case named ‘Execution’.
Katalon Studio implements the concept of Test Listener which is essentially a block of code that gets executed before and after every test case. Using this mechanism as a workaround, what @Russ_Thomas means is that you can use something like this. ( I haven’t tested it yet, but it should give you an idea )
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import internal.GlobalVariable as GlobalVariable
import com.kms.katalon.core.annotation.BeforeTestCase
import com.kms.katalon.core.annotation.BeforeTestSuite
import com.kms.katalon.core.annotation.AfterTestCase
import com.kms.katalon.core.annotation.AfterTestSuite
import com.kms.katalon.core.context.TestCaseContext
import com.kms.katalon.core.context.TestSuiteContext
class NewTestListener {
String[] dependentTestCases = new String[19]{"List of your dependent test cases' Ids"};
@BeforeTestCase
def sampleBeforeTestCase(TestCaseContext testCaseContext){
if(dependentTestCases.contains(testCaseContext.getTestCaseId()){
if(GlobalVariable.SHOULD_NOT_RUN == true){
// Do not run this test case
testCaseContext.skipThisTestCase()
}
}
}
@AfterTestCase
def sampleAfterTestCase(TestCaseContext testCaseContext) {
if(testCaseContext.getTestCaseId().equals("Your independent test case's Id")){
if(testCaseContext.getTestCaseStatus().equals("FAILED")){
GlobalVariable.SHOULD_NOT_RUN = true;
}
}
}
}
The global variable is used in your Test Listener - which will be run before and after every test case execution. It is in Test Listener that you can skip a test case depending on some conditions, and the global variable will be set to indicate that those dependent test cases should be run or not. This is achieved by setting the global variable SHOULD_NOT_RUN to true when the test case which others depend on has failed ( in afterTestcase function in TestListener ).
The error message indicates that something is wrong with your Test Listener and not your Test Cases. Could you provide a screenshot of your test listener ?
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
class NewTestListener {
String []dependentTestCases = new String[19]{“List of your dependent test cases’ Ids”};
@BeforeTestCase
def sampleBeforeTestCase(TestCaseContext testCaseContext){
if(dependentTestCases.contains(testCaseContext.getTestCaseId())){
if(GlobalVariable.SHOULD_NOT_RUN == true){
// Do not run this test case
testCaseContext.skipThisTestCase()
}
}
}
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
if(testCaseContext.getTestCaseId().contains("Test Cases")){
if(GlobalVariable.SHOULD_NOT_RUN == true){
// Do not run this test case
testCaseContext.skipThisTestCase()
}
}