JGiven
JGiven copied to clipboard
@ScenarioState fields are not transferred to @ScenarioStage when no method in injected stage is invoked
Hi there,
I'm using a global configuration object that is shared across the stages via @ScenarioState. When an additional stage with @ScenarioStage is used, I have to invoke a method there, otherwise the @ScenarioState is not shared. As this global configuration is also used in the after methods, it is important that @ScenarioState fields are also shared as this has some side-effects since I don't have to use the injected stage in all cases.
Best regards, Niko
Ok. This behavior is basically by design. As long as you don't call a method on a stage, the stage is not considered to be part of the scenario. Although @BeforeScenarion
and @AfterScenario
methods are still executed. So I guess we would have to introduce some additional mechanism/annotation for that.
I see. Then I think it is actually more consistent if beforescenario/afterscenario are also not invoked, but this might be tricky in some cases.