How to control TEST CASE STOP/CONTINUE in test plan(test suit)

There are many test cases in my test suites,I want to STOP/CONTINUE the whole process when some key-test-case fails;like ‘user_login’
It looks like ‘FailureHandling.STOP_ON_FAILURE’,but I can not use this method to control my case in suites(process)

i think you need to implement some kind of semaphore : global variable common to all TC in TestSuite
All TC will assert this variable on beginning and based on value either continue or fail.

1 Like

Andrej Podhajský said:

i think you need to implement some kind of semaphore : global variable common to all TC in TestSuite
All TC will assert this variable on beginning and based on value either continue or fail.

Thank you for giving me the idea.
but katalon 5.7+ Is there any built-in method? Because it’s very like ‘FailureHandling’
step in case ‘ok’
case in suit ‘how todo’

Jester said:

Andrej Podhajský said:

i think you need to implement some kind of semaphore : global variable common to all TC in TestSuite
All TC will assert this variable on beginning and based on value either continue or fail.

Thank you for giving me the idea.
but katalon 5.7+ Is there any built-in method? Because it’s very like ‘FailureHandling’
step in case ‘ok’
case in suit ‘how todo’

step in case ,step FAILURE case stop
case in suit ,case FAILURE suit(whole process) stop

Test Cases under a Test Suite are controlled to be independent each other. Suppose Test Suite TS0 has 2 Test Cases TC1 and TC2. Regardless TC1 passed or failed, TC2 will be invoked by TS0. In other words, A Test Suite is just a bunch of test cases, it has no capability to control flows.

Jester, you want to skip invoking TC2 in case TC1 failed, right? Test Suite is not capable of doing it.

However Katalon Studio provides an alternative approach. A test case can call another test case.

You make another test case TC0, which calls existing TC1 and TC2. Let me call TC0 as Controller. The Controller TC0 is coded as follows:

WebUI.callTestCase(findTestCase('Test Cases/TC1'), [:],    FailureHandling.STOP_ON_FAILURE)WebUI.callTestCase(findTestCase('Test Cases/TC2'), [:])

The Test Suite/TS0 will invoke TC0 only.

If you run TS0 > TC0 > TC1 fails, then TC0 will also fail immediately without calling the next:TC2.

Jester,

Don’t you like Controller?

1 Like

Please note that WebUI.callTestCase() can return any value to caller. Based on the value returned , Controller may perform any flow control you like.

def result = WebUI.callTestCase(findTestCase('Test Cases/TC1'), [:],                                FailureHandling.CONTINUE_ON_FAILURE)
if (result == 'GOOD') {
    WebUI.callTestCase(findTestCase('Test Cases/TC2'), [:],
                       FailureHandling.CONTINUE_ON_FAILURE)
} else {
    WebUI.callTestCase(findTestCase('Test Cases/TC3'), [:],
                       FailureHandling.CONTINUE_ON_FAILURE)}
1 Like

hi, my bro kazurayam.I am glad to have received your reply again in the forum.Thank you for answering me.

Controller method in case call case,I’ve understood and used this feature.

But when I organize my test scenario, it should not be a case level. Many times I need to organize my cases in Test suit.
It is strongly recommended that katalon can have something like a controller at the suit level,

Jester, I had similar problem to solve and I did this this way: in the first test case, which is definitely the most important in my test suite, I have added System.exit() after assertion failed and that caused stopping the whole test suite from further execution. Tests are running automatically from batch file after build on development level and if the first test case was failure then I automatically get an info on Slack.

1 Like

Grzegorz Obyrtacz

that is a nice solution, but the question is:

Using System.exit() will still generate an (html) execution report? I think this is generated only at the end … or system.exit it is an abnormal exit …

1 Like

another solution, using the SEMAPHORE concept, can be like this:

- define a boolean global variable, let’s say SEMAPHORE, with a default value of false

- the test suite will always start with a dummy test case, lat’s say TC0, containing only a line of code:

 GlobalVariable.SEMAPHORE = true

(or this can be set to true in the test suite before listener)

- all other testcases have the steps encapsulated in an if … else statement, kind of:

if (GlobalVariable.SEMAPHORE) {
    GlobalVariable.SEMAPHORE = false
    // do steps
    assert true
    GlobalVariable.SEMAPHORE = true
} else {
    WS.comment('Test skipped')
}

By this way, if any of the test fail at a certain moment, the others will just do the ‘test skipped’ comment … i think.

A bit ugly but it may fit for certain not too large test suites

1 Like

but in the end … having a feature /keyword like ‘Execution.STOP’ will be of a great help

1 Like

I have got a solution solution to this years-old problem: