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 setup, setup_all callbacks #71

Open
revati opened this issue Feb 27, 2019 · 5 comments
Open

Support setup, setup_all callbacks #71

revati opened this issue Feb 27, 2019 · 5 comments
Labels
1.0 enhancement ExUnit Mimic ExUnit.Case functionality as close as possible

Comments

@revati
Copy link
Collaborator

revati commented Feb 27, 2019

setup_all -> should initialize test file scope
setup -> should be able to setup scenario, alternative to background.

How they should be behaving together?

@revati revati added enhancement ExUnit Mimic ExUnit.Case functionality as close as possible labels Feb 27, 2019
@hauleth
Copy link
Contributor

hauleth commented Feb 27, 2019

Background should be translated to setup and that is it.

@revati
Copy link
Collaborator Author

revati commented Feb 27, 2019

@hauleth Yeah, they should do the same thing. Where

  • setup is more technical setup functionality
  • the background is more domain setup functionality

From this it seems that workflow should be as follows:

  • setup_all
  • setup
  • background
  • feature steps
  • all exits

@revati revati added the 1.0 label Feb 28, 2019
@mononym
Copy link
Contributor

mononym commented Mar 4, 2019

The issue with background === setup is that this might break developer expectations. My first implementation did exactly that, but the thing is that ExUnit maintains the order that setup callbacks are defined.

Given the code replacement that is happening behind the scenes, if a developer writes an explicit setup block anywhere underneath the 'using' line, their setup block will run after tags and after background steps.

This is fine for tags, as they are a before/after thing which follows the Gherkin spec. But I think it would break expectations to have user defined 'setup' blocks run after the background steps.

Now I would argue if you're using Cabbage you shouldn't be writing explicit (ExUnit) 'setup' blocks when you should be using background steps, but there is still something to be said for making the experience as smooth as possible and minimising surprises.

@hisapy
Copy link

hisapy commented Mar 4, 2019

Perhaps a good documentation with recommendations like beware if you use setup and background would fit most of the use cases (?)

@mononym
Copy link
Contributor

mononym commented Mar 5, 2019

I think calling it out explicitly would definitely be a good thing, and like you said would cover most use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 enhancement ExUnit Mimic ExUnit.Case functionality as close as possible
Projects
None yet
Development

No branches or pull requests

4 participants