聲明:我對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