Is it possible to make soft assert in Katalon?

Hello dear community (so warm when I think how active you are guys and how this place is incredible)!

I’m just wondering if there any way to make asserts work in a soft way. Here I was actually posting the question, but it looks like that documentation is checked not so often:

https://docs.katalon.com/katalon-studio/docs/assert-statements.html#assert-statement-in-scripting-view

I configured my project that it goes on test execution on failures, but for asserts it doesn’t work. I’ve seen that there is an interface for configuring failure handling:
image

But it doesn’t change behavior if you choose “Continue On Failure”, when assert fails, your test case stops running. Is there any way to make soft asserts in Katalon?

Would be very grateful to get any advise!

Hello there,

what do you mean by soft assert? What should be expected output?

HI Marek,

By soft assert I mean when my test fails at assert, it goes on working (such behaviour I want to achieve), I mean executing the next steps in my test case after this failed assert till the end. And then show in log failed step. Right now the test just stops executing when assert fails. Let me know, if you need more clarifications.

You can try to set CONTINUE_ON_FAILURE globally in Project - Settings menu. But I think this is related only to Katalon’s keywords. When you call assert method, it throws other exception which must be handled separately.

But you can still use condition instead of assert, like this:

if(similar) {
    // do whatever for true result
} else {
    // false action
}

Here you can call KeywordUtil.markFailed("custom message") and thanks to global CONTINUE_ON_FAILURE settings, it’d fail at the end of the test.

1 Like

Hi @yuliya.h

Maybe the following article would be of interest for you.

You can use SoftAssertions in Katalon Studio’ script mode. I haven’t tried it yet, but it looks promising, so please do try it out.

Cheers !

1 Like

Thank you Marek,

My project is already configured so that it continues on failures:
image

But yeah, this assumption I think correct that this applies only to Katalon keywords, since I’m using my own keywords with assert.

I will think about conditions, but actually I don’t like this approach. Anyway, thank you!

Hey Thanh,

Yeah, I found the similar way to use JUnit for soft assert, but decided to ask if there any out-of-the-box method before.

Thank you, looks like I must try this way :slight_smile:

1 Like

import org.testng.asserts.SoftAssert;

SoftAssert softAssertion=new SoftAssert();

// Katalon Code

System.out.println(“Test Step 1”);
softAssertion.assertTrue(true);

System.out.println(“Test Step 2”);
softAssertion.assertTrue(false);

System.out.println(“Test Step 3”);
System.out.println(“Test Step 4”);
softAssertion.assertTrue(false);

System.out.println(“Test Step 5”);
softAssertion.assertEquals(“Google”, “Bing”)

System.out.println(“Test Step 6”);

softAssertion.assertAll();

1 Like

Thank you discover.selenium! Will try this out!