def siteNameChange():File={
for(line<-Source.fromFile("RecordedSimulation_0000_NewSiterequest2.txt").getLines())
if(line.contains("siteUrl"))
println(line)
return new File("RecordedSimulation_0000_NewSiterequest2.txt")
}
val scn = scenario("RecordedSimulation")
.exec(http("request_0")
.post(“/student/new”)
.body(RawFileBodyPart(session=>siteNameChange())).asJSON)
您好,我是Gatling的新手,正在使用它进行性能测试。我有一个名为siteNameChange()的函数,该函数在对文件进行一些修改后会返回文件。 我正在场景主体中调用此函数来发送数据。
但是当我运行脚本时,我得到了scala:48:26:缺少参数类型 .body(RawFileBodyPart(session => siteNameChange()))。asJSON)
请问有人可以在这里提出什么最好的建议,如何使函数返回修改后的文件,并通过发布请求传递文件数据
答案 0 :(得分:0)
body
不需要一个BodyPart
(用于多部分)参数,而是一个Body
参数。
您应该传递一个RawFileBody
。