邮递员 - 如何生成特定范围内的随机数?随机数、邮递员、范围内

由网友(簡單の暖﹎)分享简介:我需要为邮递员生成特定范围内的随机数.从我在 邮递员网站是:I need to generate random number in specific range for postman.I wonder if there is possible to generate it and to use it in var...

我需要为邮递员生成特定范围内的随机数.从我在 邮递员网站是:

I need to generate random number in specific range for postman. I wonder if there is possible to generate it and to use it in variable in postman, from what I saw at postman site is:

{{$randomint }}

将给出 1-1000 之间的随机数我已经尝试过这样做:

will give random number between 1-1000 and I already tried to do something like this:

{{$randomint(1,5)}}

获取1-5之间的数字但是邮递员没有这种选项,那么邮递员如何指定随机数的范围?

to get number between 1-5 but postman didn't get this kind of option, so how to specify range for the random in postman?

推荐答案

你可以只使用 Lodash 因为它是一个内置的 模块:

You can just use Lodash for this as it's a built-in module:

pm.environment.set("random_number", _.random(1, 5))

或者只是将数字 5 添加到 _.random() 函数中,这将是一个从 0 到 5 的数字.

Or just add the number 5 to the _.random() function and this will be a number from 0 to 5.

阅读全文

相关推荐

最新文章