Forum Discussion

TonnyLi's avatar
TonnyLi
New Contributor
2 years ago
Solved

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: ...
  • JoostDG's avatar
    2 years ago

    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)
    						}
    				}
    			}
    		}
    	}

     

  • TonnyLi's avatar
    TonnyLi
    2 years ago

    WoW! It worked! Thanks alot JoostDG!

    /Tonny