Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running background job once per feature #295

Closed
domenkozar opened this issue Feb 26, 2015 · 8 comments
Closed

Support running background job once per feature #295

domenkozar opened this issue Feb 26, 2015 · 8 comments

Comments

@domenkozar
Copy link

So currently I have implemented a tag for the Feature that runs a set of steps once per Feature (as a fixture setup).

Previously I was using Background, but that runs the steps for each Scenario.

Not sure how to really implement this, maybe add Setup which is the same as Background, but it's ran before Feature, not each Scenario?

@domenkozar
Copy link
Author

#281 does make the implementation a bit easier, but it's still not simple.

@JMVM
Copy link

JMVM commented Oct 15, 2015

One solution could be include a new specific class in model.py based on Background -but different one in order to maintain the current Background behavior- and forcing one execution per feature in the same model.py.

So since Background is added for each scenario, for example, the execution could be forced easily adding that new class only for the first scenario.

Note that for adding that new class, it would be necessary to modify formatter, etc.

@jenisys
Copy link
Member

jenisys commented Oct 27, 2015

Use scenarios with tags @setup to achieve the same effect. This works especially when you use "file locations". The Scenario with tag @setup is automatically executed in a feature if a file location is provided.

@jenisys jenisys added the info label Oct 27, 2015
@esciara
Copy link

esciara commented Jan 19, 2016

Great stuff! Could not find this documented anywhere... Would it be worth doing so? Any more details we should know about?

@mbarakaja
Copy link

@jenisys, The problem that I see using @setup with file location is that the scenario's steps run in another context, making impossible to share data with the next scenario context. Which differs of the Background behavior that appends steps into a scenario in the same context.

I think that a functionality to skip the background in a scenario is desired.

@jenisys
Copy link
Member

jenisys commented Sep 20, 2016

@mbarakaja
Then provide a pull-request with a clean implementation and I will consider it.

@aidan
Copy link

aidan commented Aug 24, 2017

Hi, I've updated #281 and I think this sort of hook should do what @domenkozar is after?

def before_background(context, background):
    if context.done_setup:
        background.skip()
        return
   do_setup(context)
   context.done_setup = True  

@stale
Copy link

stale bot commented Feb 20, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Comment to post when closing a stale issue. Set to false to disable

@stale stale bot added the wontfix label Feb 20, 2018
@stale stale bot closed this as completed Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants