Reputation: 669
I have a Gatling test which should do the following:
Question: how to emulate this with Gatling? If I chain calls like :
val scn = scenario("Test scenario").exec(_create-user_).exec(_retrive-user_).exec(_delete-user_)
setUp(scn).protocols(httpConf))
then creating and deleting user will be part of the test.
Upvotes: 10
Views: 11410
Reputation: 1
In before hook we can call a method which can have below code.
val httpClient = HttpClientBuilder.create.build
val httpResponse = httpClient.execute(new HttpPut(urlString))
println("StatusCode - " + httpResponse.getStatusLine.getStatusCode)
httpClient.close()
We can use HttpGet as well. Here used apache library
example : org.apache.http.impl.client.HttpClientBuilder
Upvotes: 0
Reputation: 5880
You can use the before
and after
hooks to create and delete the user.
class RetrieveUserSimulation extends Simulation {
before {
// create user
}
setUp(scn).protocols(httpConf)
after {
// delete user
}
}
You'll have to issue the create and delete HTTP requests manually. before
and after
take => Unit
thunks, not Scenario
s.
Upvotes: 18