Forum Discussion
- Daniel-yipOccasional ContributorCan I use Random class in java.util sunch as Math.random()? If I can, How to do? Thanks
- omatzuraSuper ContributorHi!
sure.. try
context.randomValue = 5 + 5*Math.random()
to generate a value between 5 and 10!?
and then us it in a request with${randomValue}
regards,
/Ole
eviware.com - Daniel-yipOccasional ContributorThanks....
I copy the following script and the copy to groovy script for testing. A Lot of error was display.
context.randomValue = 5 + 5*Math.random()
def props = testRunner.testCase.getTestStepByName("Properties");
props.setPropertyValue("randomValue", ${randomValue});
How can I generate the the random value and transfer to property? - omatzuraSuper ContributorHi!
either use property-expansion as I showes in my initial response, or write the value to a property with
def randomValue = 5 + 5*Math.random()
def props = testRunner.testCase.getTestStepByName("Properties");
props.setPropertyValue("randomValue", randomValue );
and then use a property-transfer to transfer it to some target..
Hope this helps!
regards,
/Ole
eviware.com - Daniel-yipOccasional ContributorThe following error was displayed when execute your suggest code. What should I do?
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.WsdlPropertiesTestStep.setPropertyValue() is applicable for argument types: (java.lang.String, java.lang.Double) values: {"randomValue", 5.3027697549785975} - omatzuraSuper ContributorHi!
try
...
props.setPropertyValue("randomValue", String.valueOf(randomValue) )
instead.
regards,
/Ole
eviware.com - Daniel-yipOccasional ContributorThanks. It works fine.
Related Content
- 7 years ago
- 6 years ago
Recent Discussions
- 22 hours ago