Forum Discussion

gpeeters's avatar
gpeeters
Occasional Contributor
11 years ago

[Res]setPropertyValue

Dear support team,

I would like to put a times tamp into a REST post.

How can I do this in the most efficient way?

I did an attempt by first creating a property test step with a property <orderID>

In a groovy script I defined the following :

testRunner.testCase.getTestStepByName( "Properties" ).setPropertyValue("orderId", new Date())

However I get the following error :

groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.WsdlPropertiesTestStep.setPropertyValue() is applicable for argument types: (java.lang.String, java.util.Date) values: [orderId, Fri Apr 18 15:38:34 CEST 2014] Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String) error at line: 7

What am I doing wrong here?
I am able to get the property value with the following command

def orderIdProp = testRunner.testCase.getTestStepByName( "Properties" ).getPropertyValue( "orderId" );

Kind regards,

Geert Peeters
  • you can generate a script assertion in the request with the below code:


    targetStep = messageExchange.modelItem.testStep.testCase.getTestStepByName('Properties')

    def date1 = new Date( messageExchange.getTimestamp())
    targetStep.setPropertyValue( "timestamp",date1.toString())
    def timestamp = context.expand( '${Properties#timestamp}' )



    log.info "Timestamp " + timestamp


    OR you can use this:


    def today = new Date()

    def orderIdProp = testRunner.testCase.getTestStepByName( "Properties" ).getPropertyValue( "orderId")

    log.info orderIdProp + ": "+ today
  • gpeeters's avatar
    gpeeters
    Occasional Contributor
    Thank you for the feedback.

    I found the solution by using a sub class of Date

    testRunner.testCase.getTestStepByName( "Properties" ).setPropertyValue("orderId", new Date().getDateTimeString())


    After running the script, the orderID property has a timestamp as value

    Kind regards,

    Geert Peeters