Last night to help the old colleague solved a soapui code problem, a long time useless soapui, a lot of things are forgotten, today first summarize the groovy read properties
First spit trough under soapui of Apidocs, I can hardly see what things, official website tips have so little use, but for a long time did not update, a lot of things can not find. And it's almost impossible to debug groovy code in SOAPUI.
Apidocs:http://www.soapui.org/apidocs/index.html?com/eviware/soapui/model/testsuite/testruncontext.html
Not much nonsense to say, first get the current testsuite:
def ts = TestRunner.testCase.testSuite
Get the Properties file path:
def filename = "C:\\testsuiteproperties\\currenttestingenvironment\\endpoints.properties"
Log.info "Loading properties from" + filename
Import properties using Java Packages:
Newnew java.io.FileInputStream (filename);
Use Emumeration to read the properties value and set it to the properties of Testsuite:
Enumeration E = Props.keys (); while (E.hasmoreelements ()) { = e.nextelement (); = Props.get (key); Ts.setpropertyvalue (Key, Val); " Set Property "+ key +" to "+ Val;}
This is the initialization process for a properties parameter.
Groovy Read Properties