Ask a Question

Disable test cases depending on environment

SOLVED
TonnyLi
New Contributor

Disable test cases depending on environment

In my project I have several test suites and several test cases in the each test suite. Quite normal.

All test cases have the same test steps, the differences are the payload. Something like this:

- generate access token

- Initiate

- signing

- execute

- get status

All these test steps are valid for our test environment. But for our sand box, which is more simple, we just need the following test steps:

- initiate

- execute

- get status

To be able to use the same test cases in both environments I would like to disable two test steps when executing my test cases against our sand box.

I have tried several methods but failed.

The optimal situation would be that all those test steps get disabled in all test cases when I change to the sandbox environment and get enabled when I change back to our test environment.

Could that be done on "Function Test-level", using SetUp Script/TearDown Script or using the Event Handler or are there any other methods for this?

Someone that knows?

 

4 REPLIES 4
JoostDG
Frequent Contributor

Hi @TonnyLi ,

 

In your project setup script, you could try something like this:

//given your environment config name is = "sandbox"

project.testSuiteList.each { suite ->
		suite.testCaseList.each { kase ->
			kase.testStepList.each { step ->
				if (step.name == "generate access token") {
					if (project.activeEnvironment.name.contains("sandbox")){
						step.setDisabled(true)
						}else{
						step.setDisabled(false)
						}
				}
			}
		}
	}

 

WoW! It worked! Thanks alot JoostDG!

/Tonny

nmrao
Community Hero

There is another way to achieve the same provided if you tag the tests using the feature "Tag" (or Tags)

https://support.smartbear.com/readyapi/docs/functional/ui/project.html#tags-panel

 

And one can run the tests linked to specific  Tag.

 



Regards,
Rao.
TonnyLi
New Contributor

Hm...no, not really. It is some test steps I would like to disable in every test case. Not test cases. 

cancel
Showing results for 
Search instead for 
Did you mean: