All about SOAP UI and Groovy in it

Posts tagged ‘dynamically opt’

load property files from bin directory

At times we need, SOAP UI on start up, to load some master property file(s) so that it might be helpful to proceed dynamically depending on Test Suite scenario.

That is, lets take the situation of loading different property files for QA, Testing and Dev purposes for different Test Suites in a project. In such case its better to have a master properties file having information from where to load that specific property file for a specific requirement like QA and so on.

And this master property file could be placed in %SOAP_UI_HOME%\bin directory of the SOAP UI and can be easily accessed across the Suites.

For example, say ‘testProps.properties’ file has all the master configuration details, like for QA which/from where the property file needs to be accessed, for Dev which/from where  the property file needs to be accessed, and so on.  In that case, this testProps.properties could be placed in \bin folder directly and can be accessed in Groovy directly as:

props = new java.util.Properties();

props.load( new FileInputStream(“testProps.properties”) );

and the property values can be obtained by:

props.getProperty(“QA_PROP_LOCATION”);

props.getProperty(“DEV_PROP_LOCATION”);

(QA_PROP_LOCATION, DEV_PROP_LOCATION say are the properties present in that file). Point is I didnt mention any local file system location to access testProps.properties file, and I can dynamically make a choice on the other property files (or for that matter any variable value even) depending on the Test Suite requirement.

 

(Please feel free to get back if u have any trouble…as I’m just a mail away…leave a comment otherwise)