Setup/teardown

Is there any mechanism in Gatling for handling logic that you want
executed once at the beginning/end of the test? I would like my tests
to be able to prepare their own data and clean up after themselves but
I'm not sure the best way to run some code only once globally. I
suppose I could use (misuse?) a custom feeder for the setup something
like:

val setupFeeder = new Feeder() {
  val customer = //create and return customer
  val content = //create and return content
  def next = {
    Map("customerId" -> customer.id, "contentId" -> content.id)
  }
}

In this case my feeder would always return the same data and I could
refer to ${customerId} and ${contentId} in my tests. Of course that
doesn't really help with cleanup. Is there a better way to approach
setup and teardown of data needed for tests?

Chris

Hi Chris,

Cheers,

Steph

Is there any mechanism in Gatling for handling logic that you want
executed once at the beginning/end of the test?

No

I would like my tests to be able to prepare their own data and clean up
after themselves but
I'm not sure the best way to run some code only once globally.

What I usually do is developing scripts in charge of restoring state (disk
image, database backup, etc...) and have a super script that will launch
them, and then the stress tool.
It doesn't feel right to do it in the stress tool, depending on your use
case, you might have to restore a database, mockup some services, etc...