I'm completely new to Scala and Gatling, please forgive the basic question!
I want to create an http protocol with baseUrl specified by the result of an initial http request. Or in other words:
- Get remote config as JSON, let's say from https://example.com/config.json
- Parse JSON, retrieve a specified property
endpoint - Pass that value to
http.baseUrl()
I can do this on every single scenario manually but this quickly becomes tedious (and is unnecessarily repetitive). I'd like to find a solution where I can perform this setup once at the beginning of the test run.
My instinct is to go for something like this:
object Environment {
val config = "https://example.com/config.json"
}
val httpProtocol = http("config")
.get(Environment.config)
.check(
jsonPath("$.endpoint").saveAs("endpoint")
)
.baseUrl("${endpoint}")
// ... and then later on
setUp(
// scenario.inject()…
).protocols(httpProtocol)
... but that doesn't compile.
Thanks very much for any help.