Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gatling: How to setUp and tearDown scenario

I have a Gatling test which should do the following:

  1. create user once
  2. retrieve user's data according to specific load model. Actual load testing.
  3. delete user after when done

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.

like image 269
Fedor Avatar asked Mar 21 '16 11:03

Fedor


Video Answer


1 Answers

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 Scenarios.

like image 157
David B. Avatar answered Oct 07 '22 22:10

David B.