Hi,
I am defining a Gatling scenario and I would like to separate the http calls from the scenario. Instead of coding the whole definition in my scenario, I want to create a package containing all my http calls…
Instead of :
val myScenario = scenario(“Test”)
.exec(
http(“transaction 1”).post("/bla/bla").headers(…).formParam(…)…
)
.exec(
http(“transaction 2”).post("/bla/bla").headers(…).formParam(…)…
)
etc…
I want to define 1 object per http call and use them as I want in my future scenarios, like this:
val myScenario = scenario(“Test”)
.exec(myTransaction1) //defined in another object
.exec(myTransaction2) // same
The question is: what is the best way to declare my object containing the http call ?
object GetIAMToken {
def myTransaction1: HttpRequestBuilder = http(“transaction 1”).post…
}
OR
object GetIAMToken {
val myTransaction1: HttpRequestBuilder = http(“transaction 1”).post…
}
I’m quite new to Scala and I’ve read that val is evaluated when defined, and def is evaluated on call.
Also, I’ve seen this example on internet (for use of val):
Does val have the same behaviour if I define an HTTP call using it ? For example if I want to extract an ID in the json response from the server, randomly, I don’t want it to be always the same.
Thanks for your help !
Terry
This e-mail and any attachment are confidential and intended solely for the use of the individual to whom it is addressed. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. Unauthorized publication, use, dissemination, forwarding, printing or copying of this e-mail and its associated attachments is strictly prohibited.
Let’s respect the environment together. Only print this message if necessary.