[英]Gatling : Update content of JSON file before using it as request body
[英]Gatling - Reading JSON file and sending content using ElFileBody to a method
我是Scala和Gatling的新手。
我正在嘗試使用Scala中針對REST API端點的Gatling API編寫用於負載和性能測試的框架。
我有一個關於代碼片段之一的查詢,該代碼片段應該生成簽名(調用另一種方法)並將值保存在會話中。
.exec(session => {
session.set("sign", SignatureGeneration.getSignature(key, ElFileBody("abc.json").toString()))
})
abc.json -
{"device": "${device}"}
在上面的代碼中,getSignature采用參數(String, String)
。 我想讀取json文件,並將其中的$ {}值替換為供稿器,並將其作為String發送給方法。
在調試我發現的代碼時,ElFileBody將對象作為<function1>
發送,而不是其json內容。
解決方案-
val bodyExpr = ElFileBody(“ abc.json”)
val bodyStr = bodyExpr(session).get
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.