I have searched both here and via google trying to find the best way to generate random numbers in test cases. I have attempted to work with strings such as the below:
${=(int)(Math.random()*99999)+100001}
((int)(Math.random()*(1999999999-1900000000)+1900000000))
I am testing a rest web service. I am inserting a transaction and my request is as follows:
{"transaction":
[
{
"accountName":"Jim Jolly","accountIdentity":"2345","accountType":1,
"bankIdentification":
{"bankABA":"123123123","bankAcctNo":"1178907"},
"amount":10,
"transactionType":"c","secCode":"PPD","importID":"123",
"effectiveEntryDate":"${#Project#effectiveEntryDate}","consumerInHouseID":"CID",
"discretionaryData":"DD","isRecurring":false,"terminalCity":"TAMP",
"terminalState":"FL","cardExpirationDate":"1220",
"documentReferenceNumber":"123","processControlField":"PCF",
"itemResearchNumber":"4321"
}
]
}
[
{
"accountName":"Jim Jolly","accountIdentity":"2345","accountType":1,
"bankIdentification":
{"bankABA":"123123123","bankAcctNo":"1178907"},
"amount":10,
"transactionType":"c","secCode":"PPD","importID":"123",
"effectiveEntryDate":"${#Project#effectiveEntryDate}","consumerInHouseID":"CID",
"discretionaryData":"DD","isRecurring":false,"terminalCity":"TAMP",
"terminalState":"FL","cardExpirationDate":"1220",
"documentReferenceNumber":"123","processControlField":"PCF",
"itemResearchNumber":"4321"
}
]
}
I need to replace the bankAcctNo value of 1178907 with a random number between 3 and 17 each time.
What is the best way to accmplish this? Groovy script, custom property, etc?
I would ultimately like to have this function available at the project level as I will have to write 500-800 test cases and want to be able to reuse this in each test case. I am not familiar with Groovy and am very new to Ready API, so your patience and time are appreciated.
Thanks,
Cherice