cabbage
cabbage copied to clipboard
Support setup, setup_all callbacks
setup_all
-> should initialize test file scope
setup
-> should be able to setup scenario
, alternative to background.
How they should be behaving together?
Background should be translated to setup
and that is it.
@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
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.
Perhaps a good documentation with recommendations like beware if you use setup and background would fit most of the use cases (?)
I think calling it out explicitly would definitely be a good thing, and like you said would cover most use cases.