Forum Discussion

spasham's avatar
spasham
New Contributor
11 years ago

Custom properties file from a command line

Hello All,
I am trying to load cusomt properties from a properties file on a command line. However i do not have any success. Any thoughts would be greatly appreciated...

Followed the steps suggested in the SOAP UI documentation: http://www.soapui.org/Scripting-Propert ... rties.html

My properties.txt file contains name value pairs. For Example see below

DBString=test.db.test
testQueue=queue1

I am trying to pass the properties.txt file from a command line.

$ testrunner.bat -sTestSuite -Dsoapui.properties=properties.txt soapui-project.xml

In my testSuite i am using ${#DBString} so at runtime "test.db.test" is used.

Thank you in advance.

spasham.

3 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Make sure you defined DBString at project level.
    Can you try with ${#Project#DBString} instead of what you are using currently.
  • spasham's avatar
    spasham
    New Contributor
    Rao, Sorry I was out of the pocket for a while and Thank you for your reply. I am actually using what you suggested ${#Project#DBString}. Irony is i do not see that DBString is loaded from the property file.

    Thoughts?

    Regards,
    Spasham.
  • nmrao's avatar
    nmrao
    Champion Level 3
    Oh there is a catch here. It does not load the properties automatically, load script needs to be written in order to do that. This you can find when you double click the project or you may locate <con:afterLoadScript/> in soapui project, put the following code between <con:afterLoadScript>below script here</con:afterLoadScript>

    And here is the script

    def propertyFilePath = System.getProperty('soapui.properties')
    log.info 'User property file :'+propertyFilePath
    def propertiesFile = new File(propertyFilePath)
    if (propertiesFile) {
    log.info "PropertyFile "+propertyFilePath+ " exists"
    def props = new Properties()
    props.load(new FileInputStream(propertiesFile))
    props.each { key, value ->
    project.setPropertyValue(key, value)
    log.info 'Key :'+key+' Value : '+value
    }
    }
    else {
    log.error 'Unable to find file : '+propertyFilePath
    log.error 'Or check if -Dsoapui.properties jvm argument is passed to soapui/testrunner script'
    }