Is there a way to skip Test Cases based on a condition?

I’m looking for a way to skip entire test suite based on a condition.
I came across a requirement that all the test cases should be tested in http:// and https://. So i’m trying to alter the url in .csv file in @BeforeTestSuite in TestListener. Now i’m looking for a way to skip whole test suite if there is any error in changing url from http:// to https:// i.e. in @BeforeTestSuite annotation.

I think that the best way to do this would be to set up an If statement within your test setup action.
Something along the lines of:
if {https:// throws and error,}
{ skip test.}

@James1 The test case is same for both http:// and https://. Only url gets changed that too in data files. One more thing is I’m able to handle changing of http:// to https:// in @BeforeTestSuite. Only thing I need is only if any exception occurs in @BeforeTestSuite, the entire Test Suite should be skipped.

I think you only can skip a TestCase :

def sampleBeforeTestCase(TestCaseContext testCaseContext) {
1 Like

How much of an issue is it if the cases are not skipped?
An issue like that would be picked up pretty much at the start of each test.
Would it not be better to leave the test cases a they are so you have a record of when you encountered issues?

I made a work around like in before test case I’m trying to open the url and if the url loads successfully, proceed with test case. else skip the test case. Thanks for response :slight_smile:

1 Like

@manikumar.pulipati but your solution does not skip the entire Test Suit right?

@rodrigocalabretta It skips entire test suite because URL will not be opened for all the testcases in a test suite.

@manikumar.pulipati So if the first test fails his URL, all the test won’t be executed? Could you share that logic?

In my case my test depends on the previous so if on test fails, should stop the entire execution of the suit. I made mi workaround using a boolean global variable that I have to check on every setup test case and my test won’t get executed. I would prefer a keyword that stops the suit immediately beside using an if before run every test case

Please change your topic/question title or remove your Solution checkmark.

Your “solution”, using skip Test Case, may skip each test case in the entire suite but only when a certain condition holds. That is not the same thing as the problem statement:

Is there a way to skip entire Test Suite? I’m looking for a way to skip entire test suite based on a condition.

Possible title:

Is there a way to skip Test Cases based on a condition?

As to why I’m requesting this: This forum is meant to be a Knowledge Base. A user searching for a solution to the same problem as stated may not be satisfied with your solution which relies on (potentially unique) circumstances in your test environment.

Thanks for your understanding.

UPDATE: I made the change for you.

the following post of mine may concern to it: