# How to Fail/Skip a test case based on one or more validations

**URL:** <https://forum.katalon.com/t/how-to-fail-skip-a-test-case-based-on-one-or-more-validations/28223>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [June 19, 2019, 1:50pm UTC](https://forum.katalon.com/t/how-to-fail-skip-a-test-case-based-on-one-or-more-validations/28223 "2019-06-19T13:50:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpurohit](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mpurohit](https://forum.katalon.com/u/mpurohit)\
**Post date:** [June 19, 2019, 1:50pm UTC](https://forum.katalon.com/t/how-to-fail-skip-a-test-case-based-on-one-or-more-validations/28223/1 "2019-06-19T13:50:50Z")

</div>

**Objective:** I want to perform few validations (checks) for each test case on test case variables and stop it from executing with proper error message in logs, IF any of the validations fails.

**Current Implementation:** Right now, I’m using ‘BeforeTestCase’ listener, ‘TestCaseContext.getTestCaseVariables()’ and ‘KeywordUtil.markFailedAndStop’ to perform checks in before test case and mark it as failed; however, this does not allow me to fail/skip the test case. Even if BeforetestCase fails, respective test case executes anyway.

Expected Solution: Some way to perform validations for a given test case using its context and fail/skip it if given condition(s) are not fulfilled.

I’ve thought of below ways so far, but don’t know how to implement it.  
Is there a way, I can pass an instance of TestCaseContext for current test case in a custom keyword? Just the way we have in Listeners and then use it to validate variables.

---

<div class="post-metadata">

**Author:** ![HeleneB](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/heleneb/32/2775_2.png) [@HeleneB](https://forum.katalon.com/u/HeleneB)\
**Post date:** [June 19, 2019, 2:21pm UTC](https://forum.katalon.com/t/how-to-fail-skip-a-test-case-based-on-one-or-more-validations/28223/2 "2019-06-19T14:21:27Z")

</div>

Hi,  
You can use `testCaseContext.skipThisTestCase()` to skip the TestCase

---

<div class="post-metadata">

**Author:** ![mpurohit](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mpurohit](https://forum.katalon.com/u/mpurohit)\
**Post date:** [June 20, 2019, 11:23am UTC](https://forum.katalon.com/t/how-to-fail-skip-a-test-case-based-on-one-or-more-validations/28223/3 "2019-06-20T11:23:46Z")

</div>

Thanks HeleneB!  
The test case is now skipped and status is set to ‘SKIPPED’  
This works for me.
