Service Virtualization

Randomized Think Time Solution 

Aug 14, 2015 09:36 AM

I just recently had a requirement to randomize the response (DevTest's Think Time), between 1 - 2 seconds, and wanted to share the solution.  Just change the (2) to whatever upper range is desired.

1. In the virtual service image (vsm), add a "Java Script Step" after "VS Image Response Selection".  For Java code use:

Random rn = new Random();

int answer = rn.nextInt(2) + 1;

Thread.sleep(answer);

The 1st hit generated a think time 1.273 seconds.  The 2nd 1.812, an so on ...

Statistics
0 Favorited
3 Views
0 Files
0 Shares
0 Downloads

Related Entries and Links

No Related Resource entered.