JGiven icon indicating copy to clipboard operation
JGiven copied to clipboard

AfterScenario method seems not to be invoked for injected stages

Open adrian-herscu opened this issue 5 years ago • 0 comments

== 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

adrian-herscu avatar Oct 24 '19 13:10 adrian-herscu