Forum Discussion

robertc's avatar
robertc
Occasional Contributor
16 years ago

I am having difficulty understanding the scope of properties

I need to run my SOAPUI script against different endpoints with different userid's and passwords. I store the endpoint, userid and password in a configuration file which I read in during the setup script for a TestSuite. I then set the properties Endpoint, Username and Password to the values read in. However these properties are not recognised at the TestStep level. I would have assumed that a property defined at the TestSuite level would be available to all child TestCases and TestSteps. This is obviously not the case. Does this mean that I have to copy these properties to all test cases in the TestSuite? If so is there a means of iterating through all the TestSteps in a TestSuite from a Groovy script?
  • Hi,

    Any properties set at a point higher in the hierarchy should be visible below it, so in a TestCase you can easily access properties in the TestStep, TestCase and TestSuite. These TestSuite properties, while accessible from a TestCase, do not overwrite any values. You need to actually use read the properties for this to be of any use. This can be done using Property Expansions. For instance, if you've created properties named "Endpoint", "Username" and "Password" (These are just variable names, and could be anything), you can set the Properties on the TestStep to "${#TestSuite#Endpoint}", "${#TestSuite#Username}", etc (without quotes). When run, these expansions will dynamically be replaced with the values set in the TestSuite.

    Regards,
    Dain
    eviware.com
  • aswinisam's avatar
    aswinisam
    New Contributor
    Hi ,

    Steps:
    1)Loaded properties from external property file at the test suite level
    2) In test request of a testcase, using the property like below:

    ${#MyTestSuite#email}

    Where:
    MyTestSuite=the testsuite name
    email = the property name

    But it is loading only a null value. Please help.

    Note: I am able to see the properties loaded in the testsuite. Also I am able to use the property values(if property is loaded at the testcase level) if I use property transfer feature.
  • aswinisam's avatar
    aswinisam
    New Contributor
    This is wrt to the previous post. Forgot to mention that I am using SOAP UI 3.0.1 free version
  • Hello,

    You can't use "MyTestSuite" (ie the TestSuite name), instead you have to use the actual string "TestSuite" which will target the parent TestSuite regardless of its name. So "${#TestSuite#email}" should work.

    Regards,
    Dain
    eviware.com