1

我在下面的 api 调用中使用随机数,但它给出了错误。

"post": {
   "url":  "https://host/abc?Id=1&Amount={{{$randomNumber(4000,40000)}}}&rate={{{$randomNumber(1000000,1200000)}}}&amountType=1"
}

它给出的错误为

 { Error: Line 1: Unexpected token }
at createError (C:\Users\chintamanim\AppData\Roaming\npm\node_modules\artillery\node_modules\esprima\esprima.js:2392:21)
at unexpectedTokenError (C:\Users\chintamanim\AppData\Roaming\npm\node_modules\artillery\node_modules\esprima\esprima.js:2467:13)
at throwUnexpectedToken (C:\Users\chintamanim\AppData\Roaming\npm\node_modules\artillery\node_modules\esprima\esprima.js:2472:15)
at parsePrimaryExpression (C:\Users\chintamanim\AppData\Roaming\npm\node_modules\artillery\node_modules\esprima\esprima.js:3266:13)
at inheritCoverGrammar (C:\Users\chintamanim\AppData\Roaming\npm\node_modules\artillery\node_modules\esprima\esprima.js:2648:18)
at parseLeftHandSideExpressionAllowCall (C:\Users\chintamanim\AppData\Roaming\npm\node_modules\artillery\node_modules\esprima\esprima.js:3373:20)
at inheritCoverGrammar (C:\Users\chintamanim\AppData\Roaming\npm\node_modules\artillery\node_modules\esprima\esprima.js:2648:18)
at parsePostfixExpression (C:\Users\chintamanim\AppData\Roaming\npm\node_modules\artillery\node_modules\esprima\esprima.js:3449:16)
at parseUnaryExpression (C:\Users\chintamanim\AppData\Roaming\npm\node_modules\artillery\node_modules\esprima\esprima.js:3509:20)
at inheritCoverGrammar (C:\Users\chintamanim\AppData\Roaming\npm\node_modules\artillery\node_modules\esprima\esprima.js:2648:18)
 index: 29,
 lineNumber: 1,
 column: 30,
 description: 'Unexpected token }' }
 Unexpected error, Artillery shutting down.
4

1 回答 1

0

现在正在工作。它可以像这样使用 "{{ $randomNumber(1,3) }}" 或 $randomNumber(1,3)

参考: 如何在火炮负载测试脚本中创建随机字符串或数字?

于 2020-07-24T04:02:05.887 回答