Forum Discussion

elnreum's avatar
elnreum
New Contributor
9 years ago

soapui 5.2.1 test case property reading in mock response scripting: "No such property: testRunner"

When setting and getting a property as shown in the two attachments, the below error occurs.

How can this be solved?

 

Tue Jun 28 14:58:57 IST 2016: DEBUG:Connection closed

Tue Jun 28 14:59:41 IST 2016: DEBUG:Attempt 1 to execute request

Tue Jun 28 14:59:41 IST 2016: DEBUG: Sending request: POST /rest/dataservices/products/v2/product/search/data HTTP/1.1

Tue Jun 28 14:59:42 IST 2016:ERROR:An error occurred [No such property: testRunner for class: Script2], see error log for details

Tue Jun 28 14:59:42 IST 2016:ERROR:An error occurred [Failed to dispatch using script; groovy.lang.MissingPropertyException: No such property: testRunner for class: Script2], see error log for details

Tue Jun 28 14:59:43 IST 2016: DEBUG:Receiving response: HTTP/1.1 500 Internal Server Error

Tue Jun 28 14:59:43 IST 2016: DEBUG:Connection can be kept alive indefinitely

Tue Jun 28 14:59:43 IST 2016:INFO:Got response for [http://ece: port.Rest:REST Request] in 1702ms (92 bytes)

Tue Jun 28 15:00:17 IST 2016: DEBUG:Connection closed

 

  • Hi,

     

    The testRunner variable is not exposed within Mock scripts, there is a mockRunner instead - in other words, mocks can't access properties in that way.

     

    However mocks can access Global properties from within mock scripts e.g.

     

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

     

    Regards,

    Rupert

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    The testRunner variable is not exposed within Mock scripts, there is a mockRunner instead - in other words, mocks can't access properties in that way.

     

    However mocks can access Global properties from within mock scripts e.g.

     

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

     

    Regards,

    Rupert

    • elnreum's avatar
      elnreum
      New Contributor

      Super, Rupert. Thanks that works indeed !!

       

       

      Test case scripting:

      com.eviware.soapui.SoapUI.globalProperties.setPropertyValue("csi-iamp", "someresponse")

       

      Mock response scripting:

      def response = com.eviware.soapui.SoapUI.globalProperties.getPropertyValue("csi-iamp")
      log.info("response = " + response)
      if (response != null) {
          mockOperation.setDefaultResponse(response);
      }