How to access values in the GatlingPropertiesBuilder


I would like to access the value in requestBodiesDirectory (which is set in Engine.scala) from one of my scenarios. Is this doable? If so, how?


What are you trying to do exactly?

I have a script that needs to access data in a couple of files. Up to now I’ve simply been using src/test/resources/request/bodies/file.png and it works fine when run from within Eclipse. However, running from the command line causes problems because the file location appears to be wrong. I’m guessing that the project root is different when run from the command line.

In my MasterFlow.scala I have a Properties object, within which I previously defined something like:

val pngFileName = System.getProperty(“pngFileName”, “src/test/resources/request-bodies/large.jpg”)

And this was working fine when run from Eclipse. I was able to access this from the scenarios. But when running Gatling from the command line, the system can’t find the file.

Well, I’m sorry to say that if you don’t stick to the way of doing things we support (meaning: maven based project generated with our archetype + sbt project using our sbt plugin), you’re basically on your own.

As far as I know our process does conform with that - we use the regular scala/maven plugins. I wasn’t aware that sbt is used under the covers (although that makes sense).

The only complicated part of our scripts is that we have to generate a lot of the data during the run, so we need to be able able to access the filesystem.

We probably aren’t sufficiently Gatling proficient to have changed too many things so far, especially fundamental things. What would lead you to suspect that we have veered from the tracks? I could look into it.

You should have a look at how our maven archetype works.
It builds specific launchers.