I sometimes get asked whether it’s possible to use Cucumber to test performance. The way to do it is to specify concrete examples of scenarios that the system will find itself in under stress. For example:
Given there are 100,000 users registered on the system When I create a new account Then I should be taken to my dashboard within 5msor
Given 1000 users are hitting the homepage simultaneously Then each user should get a response within 2msTalking through these kinds of scenarios with your stakeholders will help you to understand where the boundary is for what they consider to be acceptable performance. You might find it hard to get them to be this specific at first, but help them understand that what you’re doing is drawing a line in the sand for the minimum acceptable performance – most of the time the application may be much faster than this. Now you have agreement about this, the next step is to work out how to automate these scenarios, by calling your load testing tool of choice from the Cucumber step definitions.
The key thing is to have Cucumber delegate to the stress testing tool, rather than the other way around. A common mistake people make is to simply point JMeter at existing Cucumber scenarios, but this doesn’t give you the benefit of having the parameters of the performance test documented in readable Cucumber scenarios.
These are not normal kinds of Cucumber tests. You would need to run these against an environment that’s representative of your production hardware, whereas normal behaviour scenarios could be run against any environment. It’s useful to create these scenarios early on during the project and run them against every build so they become constraints that every build must meet as the project progresses.


Ming | 24-Sep-12 at 8:42 am | Permalink
“The key thing is to have Cucumber delegate to the stress testing tool.”
Hi Matt,
Can you suggest some stress testing tools which Cucumber can delegate to?
Thanks
Matt | 24-Sep-12 at 11:28 pm | Permalink
Hi Ming,
Here’s a selection that I turned up in a recent bit of research for Cucumber Recipes:
Agata Przybyszewska | 21-Dec-12 at 11:35 pm | Permalink
My team has started on bdd, and i am looking into a way of having cucumber rule all our tests. This brought me to a search for how to make cucumber drive performance tests.
I read your blog entry, and my first thought was wow … i hurried to the pragmatic programmer website and bought the beta book (allready happily owning the cucumber book) … just to discover the current version doesnt mention anything about performance tests … now I feel slightly disappointed …
So, could you give any hints as for how to make cucumber drive a performance test … like jmeter ?
Agata
Matt | 22-Dec-12 at 12:22 am | Permalink
I’m sorry Agata, I don’t think the performance testing chapter made the cut for the Recipes Book, which is going to the printers any day now.
Keep an eye on the http://cukerecip.es/ blog and maybe we’ll post one up there.