Forum Discussion
SmartBear_Suppo
15 years agoSmartBear Alumni (Retired)
Hi Margaret,
It is possible to load global properties from the command-line by specifying -Dsoapui.properties=global-custom.properties option. Properties loaded from the specified .properties file will then show up in Preferences->Global Properties dialog and be available everywhere (i.e. all of your test projects/suites/cases/steps).
Alternatively, if you need finer control over the scope of loaded properties, you would need to program property loading manually in Groovy.
Here's one way to do it: define a command-line property that specifies the name of the .properties file which you would then access from a Groovy script and set the test case's properties like this:
If you're using Project scope for the .properties file name as i did above, you would need invoke test runner from the command-line option:
I guess this is what you needed.
Cheers!
/Nenad Nikolic
It is possible to load global properties from the command-line by specifying -Dsoapui.properties=global-custom.properties option. Properties loaded from the specified .properties file will then show up in Preferences->Global Properties dialog and be available everywhere (i.e. all of your test projects/suites/cases/steps).
Alternatively, if you need finer control over the scope of loaded properties, you would need to program property loading manually in Groovy.
Here's one way to do it: define a command-line property that specifies the name of the .properties file which you would then access from a Groovy script and set the test case's properties like this:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def propFileName
Properties extraProps
try {
log.info "About to access 'extraPropsFile' property"
propFileName = groovyUtils.expand('${#Project#extraPropsFile}')
if (!propFileName)
throw new IllegalArgumentException("Property 'extraPropsFile' not set!")
log.info "String propFile = '$propFileName'"
FileInputStream propFileInput = new FileInputStream(propFileName)
extraProps = new Properties()
extraProps.load(propFileInput)
log.info "Loaded extra, command-line props: $extraProps"
// Set the pre-defined properties in this case's test step. You can loop through all loaded properties.
// groovyUtils.setPropertyValue("Extra Properties", "someProp", propValue)
} catch (e) {
log.warn "Error: $e"
}
If you're using Project scope for the .properties file name as i did above, you would need invoke test runner from the command-line option:
testrunner.bat myproject.xml -c MyTestCase -PextraPropsFile=project-custom.properties
I guess this is what you needed.
Cheers!
/Nenad Nikolic