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?
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