如何通过GatLing-Scala中的post发送从函数返回的文件?

时间:2018-12-18 22:16:10

标签: scala-gatling

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)

请问有人可以在这里提出什么最好的建议,如何使函数返回修改后的文件,并通过发布请求传递文件数据

1 个答案:

答案 0 :(得分:0)

body不需要一个BodyPart(用于多部分)参数,而是一个Body参数。 您应该传递一个RawFileBody