How to generate a random number in a particular range
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2008
08:02 PM
03-05-2008
08:02 PM
How to generate a random number in a particular range
I want to generate a random number in a particular range, but how can write groovy script for this purpose?
7 REPLIES 7
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2008
08:32 PM
03-05-2008
08:32 PM
Can I use Random class in java.util sunch as Math.random()? If I can, How to do? Thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2008
11:36 PM
03-05-2008
11:36 PM
Hi!
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
sure.. try
context.randomValue = 5 + 5*Math.random()
to generate a value between 5 and 10!?
and then us it in a request with
regards,
/Ole
eviware.com
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2008
01:34 AM
03-06-2008
01:34 AM
Thanks....
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?
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?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2008
07:24 AM
03-06-2008
07:24 AM
Hi!
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
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2008
04:57 PM
03-06-2008
04:57 PM
The 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}
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}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2008
11:23 PM
03-06-2008
11:23 PM
Hi!
try
...
props.setPropertyValue("randomValue", String.valueOf(randomValue) )
instead.
regards,
/Ole
eviware.com
try
...
props.setPropertyValue("randomValue", String.valueOf(randomValue) )
instead.
regards,
/Ole
eviware.com
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2008
12:24 AM
03-07-2008
12:24 AM
Thanks. It works fine.
