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

**URL:** <https://forum.katalon.com/t/how-to-skip-test-case-in-a-test-suite-by-condition/10443>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [April 23, 2018, 4:09am UTC](https://forum.katalon.com/t/how-to-skip-test-case-in-a-test-suite-by-condition/10443 "2018-04-23T04:09:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JCMS](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@JCMS](https://forum.katalon.com/u/JCMS)\
**Post date:** [April 23, 2018, 4:09am UTC](https://forum.katalon.com/t/how-to-skip-test-case-in-a-test-suite-by-condition/10443/1 "2018-04-23T04:09:46Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [April 23, 2018, 7:00am UTC](https://forum.katalon.com/t/how-to-skip-test-case-in-a-test-suite-by-condition/10443/2 "2018-04-23T07:00:00Z")

</div>

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](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:

> [@A practical solution for creating reusable work-flow](http://forum.katalon.com/t/a-practical-solution-for-creating-reusable-work-flow/8378):
>
> I have demonstrated the approach I used in my project as below. The idea was that I created my workflow test cases as generic as possible and all of them have neccessary params to perform the action. These params are passing over steps with the value from Data binding area. For example: my Test Data is an excel sheet having data for a list of username, password and profile. These value are row-by-row passing to the test case in test suite, and finally passing to Workflow Test case. [image] [Tes…](https://s3.amazonaws.com/katalon-forum/editor/wn/u1a8pfpvx959.png)

---

<div class="post-metadata">

**Author:** ![JCMS](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@JCMS](https://forum.katalon.com/u/JCMS)\
**Post date:** [April 25, 2018, 6:20pm UTC](https://forum.katalon.com/t/how-to-skip-test-case-in-a-test-suite-by-condition/10443/3 "2018-04-25T18:20:03Z")

</div>

Thanks bro. It works.

---

<div class="post-metadata">

**Author:** ![Pradeep\_SV](https://avatars.discourse-cdn.com/v4/letter/p/3be4f8/32.png) [@Pradeep\_SV](https://forum.katalon.com/u/Pradeep_SV)\
**Post date:** [February 20, 2019, 1:02am UTC](https://forum.katalon.com/t/how-to-skip-test-case-in-a-test-suite-by-condition/10443/4 "2019-02-20T01:02:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ThanhTo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thanhto/32/697_2.png) [@ThanhTo](https://forum.katalon.com/u/ThanhTo)\
**Post date:** [February 20, 2019, 4:36am UTC](https://forum.katalon.com/t/how-to-skip-test-case-in-a-test-suite-by-condition/10443/5 "2019-02-20T04:36:43Z")

</div>

Hi @Pradeep_SV

Here’s the working link:

> [@A practical solution for creating reusable work-flow](http://forum.katalon.com/t/a-practical-solution-for-creating-reusable-work-flow/8378):
>
> I have demonstrated the approach I used in my project as below. The idea was that I created my workflow test cases as generic as possible and all of them have neccessary params to perform the action. These params are passing over steps with the value from Data binding area. For example: my Test Data is an excel sheet having data for a list of username, password and profile. These value are row-by-row passing to the test case in test suite, and finally passing to Workflow Test case. [image] [Tes…](https://s3.amazonaws.com/katalon-forum/editor/wn/u1a8pfpvx959.png)

Regards !

---

<div class="post-metadata">

**Author:** ![nghiact](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/nghiact/32/23870_2.png) [@nghiact](https://forum.katalon.com/u/nghiact)\
**Post date:** [June 14, 2019, 10:39am UTC](https://forum.katalon.com/t/how-to-skip-test-case-in-a-test-suite-by-condition/10443/6 "2019-06-14T10:39:05Z")

</div>

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.
