Forum Discussion

CXin's avatar
CXin
Frequent Contributor
11 years ago

How to write property value in setup script for test suiteS?

I need to set value to custom properties in setup scripts for all test suites.

Does any one know how to do that?

I tried all below scripts, neither of them work for me.


def testCaseProperty = testRunner.testCase.getPropertyValue( "MyProp" )

def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue( "MyProp" )

def projectProperty = testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" )

def globalProperty = com.eviware.soapui.SoapUI.globalProperties.getPropertyValue( "MyProp" )


The error message always say couldn't find the property.

My understanding is the custom properties for all test suites are not project property or global project, it seems they are not testSuite property either...

Please kindly help
  • Hi,

    How are you setting the property? The code you posted is getting the properties that should have already been set. If you would like to set the properties using groovy then the following methods will work.


    testRunner.testCase.setPropertyValue( "MyProp", someValue )
    testRunner.testCase.testSuite.setPropertyValue( "MyProp", someValue )
    testRunner.testCase.testSuite.project.setPropertyValue( "MyProp", someValue )
    com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "MyProp", someValue )


    That comes from our Tips n' Tricks page here, http://www.soapui.org/Scripting-Propert ... properties.


    Regards,
    Marcus
    SmartBear Support
  • Since you are in the Test Suite Setup Script, the "project" object is not available (and you need to define the 'Value' property, if you haven't). Try:

    String Value = "Some Value"
    testSuite.setPropertyValue( "PropName", Value )
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    How are you setting the property? The code you posted is getting the properties that should have already been set. If you would like to set the properties using groovy then the following methods will work.


    testRunner.testCase.setPropertyValue( "MyProp", someValue )
    testRunner.testCase.testSuite.setPropertyValue( "MyProp", someValue )
    testRunner.testCase.testSuite.project.setPropertyValue( "MyProp", someValue )
    com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "MyProp", someValue )


    That comes from our Tips n' Tricks page here, http://www.soapui.org/Scripting-Propert ... properties.


    Regards,
    Marcus
    SmartBear Support
    • sunipa054's avatar
      sunipa054
      New Contributor

      Hi,

       

      I am trying to set property in project setup and tear down . But it is giving error as "groovy.lang.MIssingPropertyException: No such property: for testRunner class: Script 12"

       

      I used: 

      testRunner.testCase.testSuite.project.setPropertyValue( "Prop", Value) 

       

      Please help on this how to resolve this issue or suggest me how t set project property under tear down step.

    • sunipa054's avatar
      sunipa054
      New Contributor

      Hi,

       

      I am trying to set property in project setup and tear down . But it is giving error as "groovy.lang.MIssingPropertyException: No such property: for testRunner class: Script 12"

       

      I used: 

      testRunner.testCase.testSuite.project.setPropertyValue( "Prop", Value) 

       

      Please help on this how to resolve this issue or suggest me how t set project property under tear down step.

      • Bill_In_Irvine's avatar
        Bill_In_Irvine
        Contributor

        It suggests "Prop" does not exist at the project level. Can you try writing out the existing properties using getPropertyNames() in some sort of loop? And in the loop use log.info to write out the names?