Forum Discussion

lszp's avatar
lszp
New Contributor
9 years ago
Solved

Reload properties from externalfile automatically

Hello all,

 

I'm doing some functionnal test using SoapUi. For some tests I need some properties which change dynamically. In order to update them on each test, a small program write an external properties file on my hardDisk with the new values. Then on soapUi properties test step, I load it using "Reload the current properties from the selected file" button.

 

My question is is there a way to automatically run the reload function, each time I start the testCases, before running the soap/rest requests?

 

Regards.

  • You should be able to load the properties from file using groovy script.

    Below script will load the properties at test case level.

     

    def props = new Properties()
    //replace the path with your file name below
    new File("/absolute/path/of/test.properties").withInputStream { s ->
      props.load(s) 
    }
    props.each {
    	context.testCase.setPropertyValue(it.key, it.value)
    }

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    You should be able to load the properties from file using groovy script.

    Below script will load the properties at test case level.

     

    def props = new Properties()
    //replace the path with your file name below
    new File("/absolute/path/of/test.properties").withInputStream { s ->
      props.load(s) 
    }
    props.each {
    	context.testCase.setPropertyValue(it.key, it.value)
    }
    • lszp's avatar
      lszp
      New Contributor

      Hello,

       

      Thank you for your response, I'll implement this.

       

      Regards.

       

      PS: sorry I post this question in the wrong thread.

    • Niyati's avatar
      Niyati
      New Member

      Thanks for code.

      Its working absolutely perfect.    :smileyhappy: