JGiven icon indicating copy to clipboard operation
JGiven copied to clipboard

@ScenarioState fields are not transferred to @ScenarioStage when no method in injected stage is invoked

Open nikowitt opened this issue 8 years ago • 2 comments

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

nikowitt avatar Feb 13 '17 09:02 nikowitt

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.

janschaefer avatar Feb 13 '17 09:02 janschaefer

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.

nikowitt avatar Feb 13 '17 12:02 nikowitt