Gatling for functional testing

1,595 views
Skip to first unread message

Stephen Ash

unread,
Oct 19, 2012, 4:35:38 PM10/19/12
to gat...@googlegroups.com
My team is currently using JMeter quite heavily, but we are out growing it and I am evaluating Gatling. Our JMeter scripts are mainly functional tests of the APIs (one user, one loop) that are executed via a maven test target.

I was wondering if anyone here could provide some anecdotes for using Gatling in a functional testing manner. Has anyone wrapped their scenarios with something like JUnit so that suites of test scenarios can be run on the continuous integration builds?

These same scenarios ideally would later get converted to load tests by passing in the number of users via JAVA_OPTS and could be executed directly (not using JUnit).

Thanks

Stéphane Landelle

unread,
Oct 20, 2012, 1:12:25 AM10/20/12
to gat...@googlegroups.com
Hi Stephen,

There would be actually 2 ways of having integration tests with Gatling:
  1. Integrate Gatling with Jenkins (if you have one of course)
  2. Integrate Gatling with a test framework such as JUnit 
Regarding 1: there's already a Jenkins plugin. It's functional, but we haven't released it yet because we might first refactor things for reasons I'll explain below.
You can find the code here:

Regarding 2: Gatling currently doesn't return a result or throw an exception and doesn't provide an API for setting acceptance criteria. An embryo of such an API has been introduced in the Jenkins plugin, but we're considering moving it into Gatling core.

If you're in a hurry, I'd advice you go with the Jenkins plugin if you can.

Cheers,

Stéphane

2012/10/19 Stephen Ash <steph...@gmail.com>

Stephen Ash

unread,
Oct 22, 2012, 1:33:09 PM10/22/12
to gat...@googlegroups.com
Thanks for the pointer to the Jenkins plugin. I'll try using that and see how far I get.

Stéphane Landelle

unread,
Oct 22, 2012, 1:40:41 PM10/22/12
to gat...@googlegroups.com
Feel free to ask if you have any question.
Good luck,

Stéphane

2012/10/22 Stephen Ash <steph...@gmail.com>

Dino Fancellu

unread,
Aug 18, 2013, 4:44:53 PM8/18/13
to gat...@googlegroups.com
Any progress on this?

Would be nice to run gatling inside junit or some Scala test framework and be able to assert against various success criteria.

What about these?


Could they integrate with the above, so when gatling fails those assertions then so does the unit/integration test?

Thanks,

Dino.

Pierre DAL-PRA

unread,
Aug 18, 2013, 4:55:01 PM8/18/13
to gat...@googlegroups.com
Hi,

The API Stéphane was talking about is the Assertions API and if you're running Gatling with the Maven plugin, the build automatically fails in case of failed assertions.
You can therefore use Gatling for functional testing, just setup the Maven plugin in your build and some assertions in your simulation and you're good to go ;-)

Cheers, 

Pierre

--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dino Fancellu

unread,
Aug 18, 2013, 5:05:59 PM8/18/13
to gat...@googlegroups.com
Ah, thanks for that. 

No, currently running Gatling inside Eclipse via the Maven architype, i.e. Engine.

Any way of getting at those assertion errors from Engine or similar? I see that the last things it does is run Gatling.fromMap(Map[String,Any]) returning an Int.

Where are they actual failed assertions stored?

Then I could call Gatling inside on of my tests, throwing some assertion containing the Gatling failed assertions. 

Dino.

Pierre DAL-PRA

unread,
Aug 18, 2013, 5:42:23 PM8/18/13
to gat...@googlegroups.com
The integer returned by fromMap is the exit code, and there are currently 3 exit codes :
  • 0 => everything went well : no incorrect command line arguments, assertions are OK
  • 1 => Parsing of command line arguments failed
  • 2 => There were some failed assertions

So, basically, you're interested in simulations exiting with exit code 2.

Assertions are stored in the simulation, and are accessible using the assertions method (which returns a Seq[Assertion]). 
However, with the current implementation of assertions checking, result is not stored anywhere : an Assertion only store the assertion itself and the message to display.
At the end of the simulation, Gatling checks the assertions against simulations.log's data, prints the result on the standard output and only gets back a boolean telling if all the assertions are OK or not.

To sum up, you can't currently individual results for each assertions, only a global result.
Reply all
Reply to author
Forward
0 new messages