jordanh
13 years agoNew Contributor
[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.
_________________________
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.