-
Notifications
You must be signed in to change notification settings - Fork 36
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
Scenario Start/End callbacks not fired in subcontexts #74
Comments
@mgwidmann this was initially deliberate as I thought it'd be confusing to have lots of callbacks potentially triggering (and the required rules around ordering). How I would implement this would be using plain functions/modules: defmodule GlobalContextHelper do
def start(state) do
Application.ensure_all_started(:hound)
Hound.start_session
state
end
def stop(_state)
Hound.end_session
end
end
defmodule MyContext do
use WhiteBread.Context
scenario_starting_state fn state ->
GlobalContextHelper.start(state)
end
scenario_finalize fn state ->
GlobalContextHelper.stop(state)
end
end It'll mean a little boiler plate in each executed context but it'll make the order of what's happening very explicit. Do you think it would make the intended use clearer if I renamed defmodule MyContext do
use WhiteBread.Context
import_steps_from GlobalContext
end |
Yeah, that would make it clearer for sure. I'd like though to not have to define a I'd prefer to not have to move code there since theres no integration testing in the test folder, seems odd to have that code compiled and available. |
To be honest I never really anticipated there being that many contexts doing setup and finalise. The contexts are inspired by this cucumber implementation: http://behat.org/en/latest/user_guide/configuration/suites.html and when using this I've not normally seen more than a few top level contexts. Normally things like a WebContext and an APIContext (maybe a CLI context). Or a few different contexts for different user types of the system. |
Something like the following does not work:
It looks like here that steps are respected:
https://github.com/meadsteve/white-bread/blob/master/lib/white_bread/context/setup.ex#L9
But below the scenario start/end events are not (or maybe I'm wrong).
Either way I can't get the code in those events to start hound without coping and pasting it into each file. Also since the contexts are loaded first it seems, I can't do a
use HoundSetup
either...The text was updated successfully, but these errors were encountered: