對于以下加特林模擬
class DeviceSimulation extends Simulation {
var devices: List[Device] = List[Device]()
before {
// Preparing data.
devices = DataFetch.getDevices()
}
// Feed device
val devicesFeederCont: Iterator[Map[String, Device]] = Iterator.continually(devices.map(d => {
Map("device" -> d)
})).flatten
val devicesFeederToKarate: ScenarioBuilder = scenario("feederDeviceToKarate").exec(karateSet("device", session => session("device").as[Device]))
val Devices: ScenarioBuilder = scenario("Device")
.feed(devicesFeederCont)
.exec(devicesFeederToKarate)
.exec(karateFeature("classpath:features/device/Devices.feature"))
setUp(
Devices.inject(rampUsers(5).during(5 seconds))
).protocols()
}
我希望能夠Device在我的功能中注入物件:
Feature: Device actions
Background:
* url 'https://server-host'
* print 'Device obj: ', device
Scenario: Device actions
Given path '/api/device/name/', device.name
When method GET
Then status 200
但是,雖然對于背景列印,我得到:c.intuit.karate - [print] Device obj: Device(1234,989898989),對于 GET 請求,我有:
GET /api/device/name/com.intuit.karate.graal.JsExecutable@333d7..
我提到 Device 只是一個具有兩個欄位的案例類:
case class Device(id: Int, name: String).
有沒有辦法在空手道功能中正確使用從進紙器傳遞的物件?
uj5u.com熱心網友回復:
現在我們只測驗了傳遞給 Gatling 會話的原始值。如果您將資料轉換為java.util.Map. 所以也許你最好的選擇是toMap()在你的資料物件上寫一些函式。或者,如果您設法發出 JSON 字串,則有一個karate.fromString()有用的助手。
所以請閱讀這里的檔案并弄清楚什么是有效的:https ://github.com/karatelabs/karate/tree/master/karate-gatling#gatling-session
非常歡迎您貢獻代碼來改善事物的狀態。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/459755.html
