Forum Discussion

JoostDG's avatar
JoostDG
Frequent Contributor
3 years ago

How to set "store locally" to default = true (or how to set it via groovy script)

Hi, I am trying to get store ALL of my properties locally (see https://support.smartbear.com/readyapi/docs/testing/properties/local-properties.html). This because a simple run of my tests dynamicall...
  • JoostDG's avatar
    JoostDG
    3 years ago

    Thanks DLeidelmeijer !

    Your solution works, I did needed a little adaptation to get it working for both test suite & test case properties. Below a project setup script that makes sure that each time it runs ALL properties (excluding of course project properties) are set to save locally.

    Cheers!

     

    EDIT: You might also add this to the "save script" via project-settings, as technically speaking it's more fit to be set there than in the project setup script. On the  save script: You might need to disable the checkbox in your preferences as otherwise you get the message "Save script might contain malicious code...". It's not clear to me why, or why this save script feature is so very hidden...

     

    project.testSuiteList.each { suite ->
    //Set all testSuite properties to "userSpecific" = true. We store value locally so it will not be saved into the GIT track changes.
    	for (prop in suite.getPropertyList()){
    	prop.setUserSpecific(true)
    	}
    //Set all testCase properties to "userSpecific" = true. We store value locally so it will not be saved into the GIT track changes.
    //note: We cannot use the wording "case" in below for each as "case" is reserved when we use a project setup script, so we use here "testkase" 
    	suite.testCaseList.each { testkase ->
    		for (prop in testkase.getPropertyList()){
    		prop.setUserSpecific(true)
    		}
    	}	
    }