cabbage-ex / cabbage

Story BDD tool for executing elixir in ExUnit
MIT License
138 stars 33 forks source link

Support setup, setup_all callbacks #71

Open revati opened 5 years ago

revati commented 5 years ago

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

How they should be behaving together?

hauleth commented 5 years ago

Background should be translated to setup and that is it.

revati commented 5 years ago

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

From this it seems that workflow should be as follows:

mononym commented 5 years ago

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 commented 5 years ago

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

mononym commented 5 years ago

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