声明:我对Scala并不熟悉,所以我可能会做一些愚蠢的事情。类型不匹配:找到字符串,要求io.gatling.core.validation.Validation [String]
我们正在使用Gatling进行性能测试。目前,我想要得到它提交POST请求我们的API,使用类似以下内容:
exec(http("post request")
.post("http://ourApi")
.body(
StringBody(
session => """{ "myContent": "value" }""" // 1
)
)
.asJSON
.check(status.is(200))
)
正如你所看到的,我使用的是表达功能为StringBody
在行标// 1
,这应该是可能的according to the Gatling documentation。
当我尝试运行,但是,我得到一个错误ZincCompiler对确切行:
type mismatch;
found : String("{ \"myContent\": \"value\" }")
required: io.gatling.core.validation.Validation[String]
为什么期待Validation[String]
?在本文档中我只看到字符串,以及...
我们需要看你的进口。你有没有包含'import io.gatling.core.Predef._'? –
@Ivan你应该发布这个答案,而不是评论,因为它很可能是正确的。 –
这似乎是@IvanBalashov,猜测它真的是时间来修复我坏了的IDE ...任何指向什么导入以及它如何神奇地将我的字符串转换为正确的类型?我很想知道它是如何在斯卡拉实际工作的... – Vincent