Forum Discussion

Buschfunk's avatar
Buschfunk
Frequent Contributor
10 years ago

Loading properties from file via Groovy

Hello,

I have defined several custom properties on test case level. Is it possible to call the "Load properties from file" functionality from a Groovy script? If yes, how can I do that?

Sincerely,
Robert
  • nmrao's avatar
    nmrao
    Champion Level 3
    You can have do it with setup script for the test case.

    1. Define a test case level property say PROPERTY_FILE_NAME and have absolute path of property file.
    2. For the test case, do a double click, you can see Setup Script. Have below script.

    def props = new Properties()
    new File(context.expand('{#TestCase#PROPERTY_FILE_NAME}')).withInputStream {
    stream -> props.load(stream)
    }
    props.each {
    testCase.setPropertyValue(it.key,it.value)
    }


    This script will run each time when test case is invoked.
  • nmrao's avatar
    nmrao
    Champion Level 3
    Looks you are a soapui pro user, try posting quries in pro boards for faster response.