Forum Discussion

jordanh's avatar
jordanh
New Contributor
13 years ago

[Res.] Script to set the value of a DataGen:Number property

I've been working with eviware support on this, but still looking for a solution. Emails below.

_________________________
Hi,

How do I set a DataGen Number property to a specific value in the middle of testCase (using a script, or some other method)?

I tried:
testRunner.testCase.testSteps["DataGen"].getProperty( "IDIncrement").setCurrent(0d)

but that gives:
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.datagen.WsdlDataGeneratorTestStep$PropertyProxy.setCurrent() is applicable for argument types: (java.lang.Double) values: [0.0]

Thanks,
Jordan.

Background:
I'm using a DataGen Number property set to READ mode to automatically generate unique IDs.

For one test, I need to send a request with multiple unique IDs, then send a follow-up message using the same IDs (I'm testing a modify action).

I'd like to use a script to reset the Number property back to 0 between the first and second requests, so that it will generate the same IDs again. So the test steps look like this:
1. DataGen - holds the Number property. Let's call it IDIncrement. Start at 0.
2. Test Request - send a create message to add three records. Each record's ID comes from IDIncrement.
3. Script - Reset IDIncrement back to 0.
4. Test Request - Send a modify message. The IDs come from IDIncrement again. Since it's been reset, the ID's are the same as in (2).

The apidocs seem out of date on this - WsdlDataGeneratorTestStep.getProperty() appears to return a PropertyProxy inner class instance, instead of the documented DataGeneratorProperty. See http://www.soapui.org/apidocs/pro/com/e ... tStep.html.

The number of records added/modified at once is variable from a DataSource - could be 2, could be 10, so individual properties for ID1, ID2, etc is not really an option.

_____________________________
From: SmartBear Sweden Support
To: ...
Date: 26/09/2011 11:17 Pm
Subject: [#FLE-121-54232]: Script to reset a DataGen:Number property to 0

HI,

you should try this instead:
testRunner.testCase.testSteps["DataGen"].getProperty( "IDIncrement").setValue( 0 )

BTW You are right published API is not up to date , thanks for reporting.

Hope this helps

regards
nebojsa
SmartBear Software
eviware.com

________________________
Hi again,

Running this:
testRunner.testCase.testSteps["DataGen"].getProperty( "IDIncrement").setValue( 0 )
gives a MissingMethodException (the method doesn't exist for an integer/double argument, only for a string argument).

Running this:
testRunner.testCase.testSteps["DataGen"].getProperty( "IDIncrement").setValue("0")
testRunner.testCase.testSteps["DataGen"].getProperty( "IDIncrement").getValue()
returns "3". Running it a second time returns "4" (because IDIncrement is in READ mode), so the setValue() call doesn't seem to be doing anything.

Any other suggestions? I'm using soapui-pro-4.0.1-daily-2011-08-31-[3].

Thanks,
Jordan.

4 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Please try the following:

    testRunner.testCase.testSteps["DataGen"].getProperty("IDIncrement").getProperty().setCurrent(0)


    Hope this helps.

    regards!
    Predrag
    SmartBear Software
    • vidyasnivas's avatar
      vidyasnivas
      Frequent Visitor

      I am facing the same issue but the solution proposed here does not seem to be working for me.

      I get the following error when I used this response in my Groovy script:

       

      "groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.datagen.NumberProperty.setCurrent() is applicable for argument types: (java.lang.Integer) values: [0] Possible solutions: getCurrent() error at line: 3"

       

      Please help.

       

      Thanks in advance,

      Vidya

       

       

      • groovyguy's avatar
        groovyguy
        Champion Level 1

        vidyasnivas : Please start a new post and describe your problem in full detail and provide a copy of your groovy script. Hijacking and reviving a thread that is years since dead cam typically confuse the situation at hand and you may not get the help you want.