JGiven
JGiven copied to clipboard
AfterScenario method seems not to be invoked for injected stages
== Context == Stages added as per documented here http://jgiven.org/userguide/#_stage_injection
As described in http://jgiven.org/userguide/#_dynamic_adding_of_stages Before/AfterScenario methods are supposedly invoked for these stages.
== The issue == I have no time to prove it now but it appears that having:
class Test extends ScenarioTest<G,W,T> {
@ScenarioStage
protected G extraFixtures;
@ScenarioStage
protected W extraActions;
@ScenarioStage
protected T extraVerifications;
@Test
public void shouldDoSomething() {
given().something();
extraFixtures.given().something();
....
extraVerifications().then().it_should_work();
then().it_should_work();
}
}
At least in my case, the @AfterScenario method is not called for the extraXXXX scenario.
** I am running on TestNG, so this behavior might be specific to that only. ** Sometimes we need to work with several similar resources, e.g. two database connections or two browsers, in order to test some messaging scenario; in such cases the additional resource is not released