[rspec-users] Any plans for Before-feature or Before-all steps in Cucumber?

Ben Mabey ben at benmabey.com
Wed Dec 3 11:59:08 EST 2008


Ashley Moran wrote:
>
> On 2 Dec 2008, at 15:26, Joseph Wilk wrote:
>
>> BeforeAll (Before running any feature) is currently possible through 
>> putting something in your env.rb or really any ruby file that gets 
>> required. It will be run once (and before anything else).
>> I use this to manage ferret/selenium. The before/afters being used to 
>> tell the service to cleanup so we have clean environment for each 
>> test. Could you do the same?
>>
>> And Afterall is possible through: at_exit
>
> Yeah, I've had to resort to doing this, which makes the end of my 
> env.rb look like this:
>
>   #######################
>   # Start everything up #
>   #######################
>
>   require 'support/service_controllers'
>
>   # Note this relies on this file being loaded only once!
>
>   ServiceControllers.stop_all
>   ServiceControllers.start_all
>
>   at_exit do
>     ServiceControllers.stop_all
>   end
>
> I don't like this though, it's asymmetric.
>
>
>> BeforeFeature sounds like it could be useful for preparing services 
>> for that specific feature and you don't want them running for other 
>> features. I guess currently  the only way of achieving this is 
>> separating those features and running them in separate cucumber runs. 
>> This is what I have done with something similar, using --profile to 
>> run different sets of features. I prefer this (in my experience so 
>> far) as it allows me to re-use my rake tasks for setting things up 
>> and keeps that setup from adding noise to my test code. I appreciate 
>> with mock services your situation is slightly different.
>
> I see what you mean, but it's always useful to run all the features in 
> one run.  'rake features' should be the unambiguous, authoritative 
> decider of whether your code can go live (IMHO).
>
> Ashley
>
I agree with Ashley.  In the past I have done multiple profiles just as 
Joseph has suggested.  I have then modified my features task to serially 
run my different feature sets and profiles.  With that you do have one 
task you need to run.  However, it would still be very nice if these 
different profile types, even if not ran as the same process, could be 
grouped into a single report and given then appearance that it was one 
large process.  I understand the problems and difficulties of doing such 
a thing, but WDYT?  If we think there is enough value in such an 
aggregate feature set  runner/report and we can decide on the details 
then I would be willing to tackle it.

-Ben


More information about the rspec-users mailing list