How do you print values to the console for a Gatling script? [rc4]

I am using my Gatling scripts in an automated build server (Jenkins).

We are in “script tuning mode”, so I am required to change my script several times a day.

I have variables declared in my Simulation class to manage the basic inputs that determine behavior of the script. I would like to be able to print these values when the script runs (somewhere near the top of the console output), so we can have better visibility of what test parameters are being used. If this information could somehow be added to the Gatling report, that would be even better, but for now I’d be very happy to get it in the console or some other way.

My Simulation classes are all organized like this >

class StressTestCLOUDSimulation extends Simulation {

// definitions for the baseURL(s) go here…

//======================================================
// test input variables go here ( these are the ones I want to access)
val numberOfRepeats = 1

val rampUpDurationInSec = 3600
val userRampStart = 1
val rampTarget = 1800
val usersConstant = rampTarget
val totalTestPeriodInSec = rampUpDurationInSec

// calculate the rps ( or whatever else is interesting)

val testParams = 10 * (numberOfRepeats ) * usersConstant

//====================================================

// httpProtocol defined here…

// scenario (“scn”) definition here…

setUp(
scn.inject(
rampUsersPerSec( userRampStart).to( rampTarget) during (totalTestPeriod )
).protocols( httpProtocol))
}

Hi Nadine,

Regarding printing in the Console, Gatling provides two hooks: before and after. Sorry, those weren’t documented: https://github.com/gatling/gatling/commit/2864b72bf9f329f9e59a324231b90a797e0b25c3

Regarding printing in the reports, you could use the runDescription cli option: http://gatling.io/docs/2.0.0-RC5/general/configuration.html#command-line-options

Thanks Stephane.

It's good to know about the hooks and the description argument for Gatling. I think the post run hook will be especially useful because my team wants to have extra analysis done with the stats.js file, and I think this will be a good place to do the work.

As an aside, I also found a little spot to slip in some text to show in the console - by appending to the String that is normally used as a Param for declaring the scenario object.

Ex.
Val scan = scenario( "scenario name - followed by my sneaky string content")
  .exec( blah)

Of course, this will also make the text appear with every single 5 ms checkpoint in the console instead of just once at the beginning, but for certain types of information (such as RPS sent by the script or endpoint), that is probably not a bad thing.