Assertion inside the custom keyword

I am trying to use Hard and Soft Asserts in custom keywords for API testing. I could see that the execution flow is terminated whenever there is failure in assertion(for Hard Asserts) however, the test case status is in error not in failed. I am expecting the execution status to be in Failed instead of Error status.

Hii, can you provide more details and screenshots so it will be helpful to understand.
Also, you can use KeywordUtils for pass or fail testcase.

1 Like

@siddesh.kumarbs I did just check and you are right. While an assert directly in a test will mark a test as failed when it is in a custom keyword it is getting marked as an error. It looks like this is expected inside a custom keyword and you need to manually mark what is expected inside a custom keyword base on this link:

One way to do this is to throw the assert into an if statement and if it does not match manually mark the test as failed using the KeywordUtil.markFailed function. Here is an example:

if (variableToCheck != 'expectedValue') {
		KeywordUtil.markFailed('reason for marking failed')
1 Like

I do not see the what the terms “Hard Assert” and “Soft Assert” are. What do you mean? Could you give me some URL for reference to see what you mean.

Do you mean the Groovy languages assert statement by “Hard Assert” ?