It is possible to skip test in runtime?

We have TestSuites with TestCases on the TestRail.
After creating TestSuite with TC, I know TestSuite ID only.
In Katalon i am configured @BeforeTestSuite Listener to get TestSuite ID from file. Then Katalon connects to the TestRail, gets TestCase IDs from TestSuite and puts IDs into Collection. In Katalon i’m adding IDs to TestCase into Variable. Via @BeforeTestCase Listener i get TestCase ID from TestCase context. If Collection of IDs contains TestCase ID - test runs. Else - the test shouldn’t run. Maybe someone knows how to skip the test?

As a temporary solution i add flag into Global variable. And in the Else block i set flag to false and on tests i check this flag and use markErrorAndStop. But i think this is not good solution.
2 Likes

Agreed Dmitry, We need _markSkippedAndStop or _markBlockedAndStop keyword

3 Likes

Agree, we would also want a keyword markSkippedAndNext, markBlockedAndNext to jump to nxt iteration.

well noted! Thank you so much for the suggestion

3 Likes

Hi, any news on this feature

1 Like

Yes, there is implementation on this in the listener class

@BeforeTestCase
def sampleBeforeTestCase(TestCaseContext testCaseContext) {
			testCaseContext.skipThisTestCase()
		}

This will skip all tests, You will need to add condition

Thanks, but just as Idea:
It still would be good to have such ability maybe supply skip function as third parameter:

it(‘should skip if not fit’, function(done, skip){
if (fit) done() else (skip())
}

or maybe do it with done function by supplying some paramenters done({skip: true}), by the way done(‘some message’) output is huge and like error out, I wonder why?
source

Just FYI - we’ve built a TestRail integration plugin for Katalon Studio. If you have any feedback or suggestions we are happy to hear from you.

https://store.katalon.com/product/13/TestRail-Integration

It doesn’t acctually skip the test it just marked it as passed and run the whole execution but only doesn’t care about the result, which is pretty dummy.

I expect from the method like that to not run the test at all and to not include it in the report.

Hi @rchomicki

This method isn’t supposed to execute the test case. Does it not work for you ?

Hi, thanks for your replay.

It works only partially for me I wanted to marked some of the tests as smoke, to not divide the data table in my DDT test suite.
So it looks like it triggers the rest test execution, Listener example above:

@BeforeTestCase
def sampleBeforeTestCase(TestCaseContext testCaseContext) {

	Map<String, Object> map = testCaseContext.getTestCaseVariables()
	
	
	if (GlobalVariable.smokeSuite) {
		if (!map.get("smoke")) {
			testCaseContext.skipThisTestCase()				
		}
	}		
					
	// Ignore test case create a message in log failing tests
	if (map.get('ignore')) {
		GlobalVariable.FailedTestsList += GlobalVariable.testNumber + ": " + map.get('testName') + ": IGNORED.\n\n"
		testCaseContext.skipThisTestCase(true)
		
	}
	
	// Reset counters if resetCounters variable is set on true
	if (map.get('resetCounters')) {
		WebUI.callTestCase(findTestCase('GenericTestCases/ResetCountersForUID'), [("uid"): map.get('uid')], FailureHandling.CONTINUE_ON_FAILURE)
	}
	
	// Get last known counter value and refer it to the variable
	if (map.get('cornerCondition').equals('checkCounter')) {
		GlobalVariable.lastCounterValue = WebUI.callTestCase(findTestCase('GenericTestCases/GetDataForUID'), [('uid') : map.get('uid')], FailureHandling.CONTINUE_ON_FAILURE).get('nfcCounter')
	}		
}

I do expect from it to stop from this moment on if the test is not marked as smoke, but it seems to go further with the rest of variables, counters reset etc which is a time consuming.
Of course I can put the rest into the else block, but why does it happen?

Also I would like to have the information about the number of skipped tests, not passed in the report or even to not execute and include them in the test report at all.

Please let me know if I missed something.

Remi

Regarding this:

If you want the code to stop after skipThisTestCase is set, then you just need to add

return;

after it and the execution flow should be handed over to the next test listener or test case.

Regarding this:

I think it is a reasonable requirement, I will escalate this to the team. Thanks !

Great thanks for your advice. I though that was handled by the method itself.