# How to custom keyword show failed step

**URL:** <https://forum.katalon.com/t/how-to-custom-keyword-show-failed-step/17258>\
**Category:** Web Testing\
**Tags:** web-testing, katalon-studio\
**Created:** [January 7, 2019, 11:49am UTC](https://forum.katalon.com/t/how-to-custom-keyword-show-failed-step/17258 "2019-01-07T11:49:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cavoidc](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@cavoidc](https://forum.katalon.com/u/cavoidc)\
**Post date:** [January 7, 2019, 11:49am UTC](https://forum.katalon.com/t/how-to-custom-keyword-show-failed-step/17258/1 "2019-01-07T11:49:32Z")

</div>

# I have create a custom keyword like:

```
@Keyword
	def VerifyClientEnable(String clientName){
		KeywordUtil key = new KeywordUtil()
		CustomLog log = new CustomLog()
		try{
			connectToLHDb();
			Statement stm = connection.createStatement()
			String query = "SELECT Top (1) * FROM Account a INNER JOIN PhotoStudioClient p ON a.AccountId = p.ClientId WHERE a.AccountName ='"+clientName+"'"
			ResultSet rs = stm.executeQuery(query)
				while(rs.next()){
					Object value = rs.getObject("IsEnabled")
					System.out.println("===== LOG =====")
					System.out.println("Value: " + value.toString())
					if(value.toString().equals("true")){
						KeywordUtil.markPassed("VerifyClientEnable PASSED 1")
						System.out.println("VerifyClientEnable PASSED 2")
						log.markStepPassed()
						logger.logPassed("VerifyClientEnable PASSED 3")
					}else{
						KeywordUtil.markFailed("VerifyClientEnable FAILED 1")
						System.out.println("VerifyClientEnable FAILED 2")
						log.markStepFailed("VerifyClientEnable FAILED 3")
						logger.logFailed("VerifyClientEnable FAILED 4")
					}
				}
			}catch(Exception e){
			
			System.out.println("VerifyClientEnable QUERY FAILED 1" + e)
			KeywordUtil.markFailed("VerifyClientEnable FAILED 2")
			log.markStepFailed("VerifyClientEnable FAILED 3")
			logger.logFailed("VerifyClientEnable FAILED 4")
		}
	return false
	}

```

================================

But it can not show fail step when execute query fail, or value = false  
Please help!!!

---

<div class="post-metadata">

**Author:** ![Marek\_Melocik](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/marek_melocik/32/371_2.png) [@Marek\_Melocik](https://forum.katalon.com/u/Marek_Melocik)\
**Post date:** [January 7, 2019, 11:54am UTC](https://forum.katalon.com/t/how-to-custom-keyword-show-failed-step/17258/2 "2019-01-07T11:54:10Z")

</div>

What’s the output in case of failure?

---

<div class="post-metadata">

**Author:** ![cavoidc](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@cavoidc](https://forum.katalon.com/u/cavoidc)\
**Post date:** [January 7, 2019, 1:05pm UTC](https://forum.katalon.com/t/how-to-custom-keyword-show-failed-step/17258/3 "2019-01-07T13:05:31Z")

</div>

Show error step, red line in log, and show message log

KeywordUtil.markFailed(“VerifyClientEnable FAILED 1”)  
System.out.println(“VerifyClientEnable FAILED 2”)  
log.markStepFailed(“VerifyClientEnable FAILED 3”)  
logger.logFailed(“VerifyClientEnable FAILED 4”)

---

<div class="post-metadata">

**Author:** ![Marek\_Melocik](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/marek_melocik/32/371_2.png) [@Marek\_Melocik](https://forum.katalon.com/u/Marek_Melocik)\
**Post date:** [January 7, 2019, 1:06pm UTC](https://forum.katalon.com/t/how-to-custom-keyword-show-failed-step/17258/4 "2019-01-07T13:06:05Z")

</div>

Oh, I meant actual output. Sorry for confusion.

---

<div class="post-metadata">

**Author:** ![Ibus](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@Ibus](https://forum.katalon.com/u/Ibus)\
**Post date:** [January 7, 2019, 3:18pm UTC](https://forum.katalon.com/t/how-to-custom-keyword-show-failed-step/17258/5 "2019-01-07T15:18:50Z")

</div>

> [@cavoidc](#):
>
> while(rs.next()){

by enclosing all other check’s in this loop, there may be a chance they are never executed if **rs** is empty  
so … as @marek said … how do you simulate the failure and what is the **actual output** log?

---

<div class="post-metadata">

**Author:** ![cavoidc](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@cavoidc](https://forum.katalon.com/u/cavoidc)\
**Post date:** [January 8, 2019, 6:41am UTC](https://forum.katalon.com/t/how-to-custom-keyword-show-failed-step/17258/6 "2019-01-08T06:41:40Z")

</div>

sorry, if some things I do not understand.  
I need query to database to get a column value.  
=\> if value = true mean test case is passed  
=\> otherwise if value = false test case is failed  
when test case is failed I want to show error, failed step by “KeywordUtil.markFailed(errMes)”  
but with my code below, it still show step is passed.  
I don’t know why ?  
please help me.
