Forum Discussion

wjblazek's avatar
wjblazek
Occasional Contributor
7 years ago

messageExchange...getPropertyValue( "propName") .. setPropertyValue( "propName", propValue) issue

It appears that, in a script assertion in a test step,

NOT a separate groovy script test step,  if there is a 

messageExchange.modelItem.testStep.testCase.getPropertyValue( "propName" )

and a

messageExchange.modelItem.testStep.testCase.setPropertyValue( "propName", propValue )

in the same test step script assertion, the setPropertyValue() always get executed 1st,

even if it comes AFTER the getPropertyValue() in the script.

Is this a bug or this this somehow by design?

 

For example, a script with just 

log.info "Property value=" + messageExchange.modelItem.testStep.testCase.getPropertyValue( "propName" )

works as expected, it returns the current value of the property that can be viewed in the testCase properties list.

 

But  script with:

 

def origPropValue = messageExchange.modelItem.testStep.testCase.getPropertyValue( "propName" )

log.info "Original property value=" + origPropValue

 

....   more processing to get  a new value

 

messageExchange.modelItem.testStep.testCase.setPropertyValue( "propName",  "some_new_Property_Value" )

newPropValue = messageExchange.modelItem.testStep.testCase.getPropertyValue( "propName" )

log.info "New property value=" + newPropValue

 

prints the new property value for BOTH origPropValue and newPropValue

even though origPropValue should be set and printed BEFORE the 

new value for the property has been calculated and setPropertyValue() has run.

 

How does this happen????

How is origPropValue being overwritten?

Baffeling.

 

Thanks!

 

 

 

 

2 Replies

  • PaulMS's avatar
    PaulMS
    Super Contributor

    The Run button at the top of the window executes the assertion script against the last received response with a "mock testContext" according to the tool tip message. This may be causing the problem.

     

    When you click the OK button (or submit the request) then check the "script log" tab at the bottom of the main window you should see the correct original value.

    • wjblazek's avatar
      wjblazek
      Occasional Contributor

      Thanks for the info.

      Yes it does print out correctly in the script log.

      I didn't think to look there.

      I was just looking in the script assertion output window.