Why a feature file can't run multiple time?

1,649 views
Skip to first unread message

Anand Balasundaram

unread,
Jun 18, 2015, 11:25:24 PM6/18/15
to cu...@googlegroups.com
I want to run same feature(or scenario) multiple times. But I got to know that it was not possible in cucumber. 
Can someone explain me why it is not possible?

It will be more useful to explain it in light of the structure of cucumber.

Andrew Premdas

unread,
Jun 18, 2015, 11:28:14 PM6/18/15
to cu...@googlegroups.com
You can run a feature multiple times, you invoke cucumber once for each time you want to run it. Why would you want to put this functionality in Cucumber when it is already provided by every OS that cucumber is run on?



--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
------------------------
Andrew Premdas

Anand Balasundaram

unread,
Jun 19, 2015, 12:21:55 AM6/19/15
to cu...@googlegroups.com
Andrew,
I have tried something similar to below code.

Around(@Tag) do |scenario, block|
  5.times.block.call
end

But the matching of regular expression happened only once.
Is there anyway to get it on working?
If not Can you explain me that in terms of Cucumber API(I have read somewhere resetting the API status we can get it work the above code).
I am relatively new to cucumber. So these things seems mystery to me.
Thanks in advance.

Anand Balasundaram

unread,
Jun 19, 2015, 12:21:55 AM6/19/15
to cu...@googlegroups.com
Andrew,
I want to run a particular scenario multiple times. It is for stress testing. We have build a framework to test a firmware. Every time when we go back to OS it would be costly. So we want to run the stress test within the framework.


On Friday, 19 June 2015 08:58:14 UTC+5:30, apremdas wrote:

George Dinwiddie

unread,
Jun 19, 2015, 10:19:41 PM6/19/15
to cu...@googlegroups.com
Anand,

On 6/18/15 11:59 PM, Anand Balasundaram wrote:
> Andrew,
> I want to run a particular scenario multiple times. It is for stress
> testing. We have build a framework to test a firmware. Every time when
> we go back to OS it would be costly. So we want to run the stress test
> within the framework.

Cucumber is, at it's heart, a collaboration tool, not a stress test too.
There are other tools designed as stress test tools.

- George

--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.org
----------------------------------------------------------------------

Andrew Premdas

unread,
Jun 20, 2015, 5:19:21 AM6/20/15
to cu...@googlegroups.com
On 19 June 2015 at 04:59, Anand Balasundaram <balua...@gmail.com> wrote:
Andrew,
I want to run a particular scenario multiple times. It is for stress testing. We have build a framework to test a firmware. Every time when we go back to OS it would be costly. So we want to run the stress test within the framework.


OK, so you're trying to use Cucumber for something its not really designed for, and of course you are having problems. Here's how I would solve this:

Solution:

You have the code that executes your test - probably in your step definitions. Extract this code into helper methods. Then write a new scenario specifically for your stress test. Use this scenario to do the looping for you. An example might help:

Say your exisitng scenario is

Given foo
When I bar
Then I should see baz

and your existing step defintions are like

GIven "foo" do
  # loads and loads of code
  ...
end

You can refactor this code so it becomes something like

Given "foo" do
  do_foo
end

module Blah
  def do_foo
     # loads and loads of code
     ...
   end
end

Now you can call this method in any step definition. Assuming you've done this for all the methods in the scenario you can now do something like

Scenario: stress test
  When I stress test

And implement that as

When "I stress test" do
   1000.times do
      do_foo
      do_bar
      check_for_baz
    end
end

Or even better extract that into a method and add it to your module.

Whilst this solution might seem like alot of work you'll find it has the following benefits

1: It requires no changes to Cucumber, so you are not dependent on anybody else doing work
2: Its a general technique that applies to all sorts of other problems that Cukers have.
3. It will dramatically improve the quality of your test suite and make it much easier to write new/modified scenarios around this particular area of functionality without breaking anything.
4: It will allow much greater control in collecting and processing the results of your stress test.

HTH

All best

Andrew

Tim Walker

unread,
Jun 20, 2015, 10:37:48 PM6/20/15
to cu...@googlegroups.com
On Fri, Jun 19, 2015 at 8:19 PM, George Dinwiddie <li...@idiacomputing.com> wrote:
Anand,

On 6/18/15 11:59 PM, Anand Balasundaram wrote:
Andrew,
I want to run a particular scenario multiple times. It is for stress
testing. We have build a framework to test a firmware. Every time when
we go back to OS it would be costly. So we want to run the stress test
within the framework.

Cucumber is, at it's heart, a collaboration tool, not a stress test too. There are other tools designed as stress test tools.

[Tim] Definitely true, though something I'd like to throw out there is the power of expressing behavior of non-functional requirements to *drive* the system capabilities such that you can communicate this with the business. 

As a concrete example:

Scenario: Site page response times
   Given a system with all the domain data and all the goodies it needs to run 10,000 concurrent users
   When I run 10,000 concurrent users exercising common paths and ramps through the system for 2 hours
   Then no page response exceeds 4 seconds
   And there are less than 1% errors returned

Now, what's nice about that is that the business can understand the non-functional requirement and it's not hidden away in some 4th quadrant black hole. If the tests fail, or the engineers can only eek out 5 seconds and 2% error rate, the business might go ahead and accept this and release the software. Pretty sure the business owners of the Affordable Care Act system would have appreciated this information *before* they went live. Additionally, If you write these specifications at the beginning of a project it becomes a very effective way to manage these NFRs, iteration-over-iteration. Like an umbrella. If someone introduces new behavior, say database auditing, you'll know the impact of that on your system immediately and not when there's pressure to release at the end. 

Thanks George! Hope all is well. T

 

 - George

--
 ----------------------------------------------------------------------
  * George Dinwiddie *                      http://blog.gdinwiddie.com
  Software Development                    http://www.idiacomputing.com
  Consultant and Coach                    http://www.agilemaryland.org
 ----------------------------------------------------------------------

Paolo Ambrosio

unread,
Jun 21, 2015, 6:05:45 AM6/21/15
to cu...@googlegroups.com
Even though I usually agree with Andrew, this hardly qualifies as load testing.

I've never tried to express non-functional requirements in Cucumber,
but performance testing is much more complex than running the same
sequence of actions multiple times.

What I would do is to run a performance testing tool from Cucumber and
analyse the results. Even better, in a continuous integration pipeline
you could run all performance testing and then download and analyse
results in Cucumber (for each build).

If the performance testing tool supports scripts written in the same
language as your Cucumber step definitions, you can re-use the code
(as Andrew wrote).

Anand Balasundaram

unread,
Jun 22, 2015, 7:39:53 AM6/22/15
to cu...@googlegroups.com
Thanks George,
I am realising that now. But, As we have already written testing functionalities while writing step definitions. We want use them as much as possible. It will be totally rework if we write the functionalities which we have already developed. 
As you have mentioned about tools, can you name few tools which will helpful in stress test? 

George Dinwiddie

unread,
Jun 22, 2015, 10:45:26 PM6/22/15
to cu...@googlegroups.com
Anand,

On 6/22/15 7:39 AM, Anand Balasundaram wrote:
> Thanks George,
> I am realising that now. But, As we have already written testing
> functionalities while writing step definitions. We want use them as much
> as possible. It will be totally rework if we write the functionalities
> which we have already developed.
> As you have mentioned about tools, can you name few tools which will
> helpful in stress test?

Sorry, but I don't have enough experience with stress testing tools to
make a recommendation to you. I'd think that the capability to drive
your testing glue code would be important. What implementation language
did you use to connect your cucumber scenarios to the system under test?

- George

>
> On Saturday, 20 June 2015 07:49:41 UTC+5:30, George Dinwiddie wrote:
>
> Anand,
>
> On 6/18/15 11:59 PM, Anand Balasundaram wrote:
> > Andrew,
> > I want to run a particular scenario multiple times. It is for stress
> > testing. We have build a framework to test a firmware. Every time
> when
> > we go back to OS it would be costly. So we want to run the stress
> test
> > within the framework.
>
> Cucumber is, at it's heart, a collaboration tool, not a stress test
> too.
> There are other tools designed as stress test tools.
>
> - George
>
> --
>
> ----------------------------------------------------------------------
> * George Dinwiddie * http://blog.gdinwiddie.com
> Software Development http://www.idiacomputing.com
> Consultant and Coach http://www.agilemaryland.org
>
> ----------------------------------------------------------------------
>
> --
> Posting rules: http://cukes.info/posting-rules.html
> ---
> You received this message because you are subscribed to the Google
> Groups "Cukes" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to cukes+un...@googlegroups.com
> <mailto:cukes+un...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Anand Balasundaram

unread,
Jun 23, 2015, 1:38:26 AM6/23/15
to cu...@googlegroups.com
Am using Ruby.
Reply all
Reply to author
Forward
0 new messages