On 2010-04-30 7:36 AM, Matt Wynne wrote:
>
> On 30 Apr 2010, at 13:11, jbandi wrote:
>
>> I always wondered why step implementations are global in Cucumber?
>
> We call them 'Step Definitions' in Cucumber. I don't mean to be picky
> but it avoids misunderstandings if we use the same words for stuff.
>
>> If step implementations could be scoped to scenarios then this would
>> not be a problem. You could provide a different implementation of "I
>> add the item XXXX" for each scenario (possibly sharing some common
>> code).
>>
>> In JBehave you can do this for instance:
>>
http://jbehave.org/reference/stable/configuring-scenarios.html
>>
>> (ok it might be a bit verbose but with a bit of ruby magic this could
>> certainly be improved?)
>>
>> So, why are step implementations global? What is the idea behind that?
>
> Simply because that's all at least 80% of people using Cucumber have
> ever needed.
>
> I would not like to see mandatory mapping of step defs to scenarios
> (as JBehave seems to do), but it would be nice if there was a way to
> scope them if you wanted to.
This is what motivated me to work on my external runner script. Having
all step definitions loaded automatically seemed a bit too "loose" for
me (being a recovering perfectionist and all), so I wanted to load only
those steps that I specifically "defined" as global and ones that I
created just for the feature that I wanted to run. Ultimately, I ended
up looking for a step definition file that was named according to the
feature file name (these would be the "scoped" steps) and then
everything in a "shared" folder. In many respects, this approach worked
well for me.
But it does have disadvantages, the main one being the inability to run
all features in one cucumber instance. When I want to run the whole
feature set, each feature file gets run independently of all the others,
which means cucumber is executed for each feature. And since I currently
use C[eu]lerity, it's pretty painful.
Even though I have spent considerable amount of time creating a library
that I can work with very easily, I am giving serious consideration to
dumping it because of how long it takes to run the whole thing. And I
don't have the quick feedback loop that is so helpful when trying to go
outside-in. Even without javascript support in a scenario, it takes
10-20 seconds to fire up cucumber, culerity, celerity, run the scenario,
and get feedback. To be honest, I haven't even written a feature in
weeks. I've been trying to spec my views in RSpec and am planning on
coming back at a later date to implement features (when I can give more
time to deciding which toolset I want to use).
If Cucumber had a way of scoping that was transparent, that would have
altered my course considerably.
Peace,
Phillip