How to skip test case in a test suite by condition?

Hi guys, i’m a new beginner in automation tools and i need a help :# . Can anybody tell me how to skip a test case by condition? I have 5 test case in a test suite
1. TC A
2. TC B
3. TC C (I want this Test Case run depends on result on TC B. For example, if result X run this TC but if result Y skip this TC and go to next TC (D & E)
4. TC D
5. TC E

Thanks :slight_smile:

2 Likes

As far as I see, a Test Suite is a simple sequence of invokations of Test Cases. No IF … THEN … ELSE … is achievable.

On the other hand, a test case can call other test cases. See
https://docs.katalon.com/display/KD/Call+test+case

And you can use Groovy’s native control of if (…) { … } else {…} in a test case. It quite easy.

So you can write your TC B so that B calls either of TC C or TC D+E depending on internal state of B.

Some bright guys are discussing about implementing workflow:

2 Likes

Thanks bro. It works.

I am unable to access the response to view reusable work flow…can someone help me with this…

Hi @Pradeep_SV

Here’s the working link:

Regards !

Hi,
You can use Test Listener for this.
Step 1: Create Globalvariable TC_Status = “PASSED”
Step 2: - Create Test listener,
In, @After test
def sampleAfterTestCase(TestCaseContext testCaseContext) {

	if(testCaseContext.getTestCaseId() == 'your test case'){
		if(testCaseContext.getTestCaseStatus()=='FAILED'){
		GlobalVariable.TC_Status = 'FAILED'
	}
	if(testCaseContext.getTestCaseStatus()=='ERROR'){
		GlobalVariable.TC_Status = 'ERROR'
	}
	}
}

Step 3: Create testsuite.
In, @SetupTestCase:
@SetupTestCase(skipped = false) // Please change skipped to be false to activate this method.
def setupTestCase() {
// Put your code here.
if(GlobalVariable.TC_Status == “FAILED” || GlobalVariable.TC_Status == “ERROR”){
KeywordUtil.markErrorAndStop("---->|")
}
}

You can custom it for your access.

1 Like