0

Before/After Scenario not working in jbehave serenity BDD serenity.version 1.2.3-rc.5 serenity.jbehave.version 1.21.0

Eg

public class UploadDocumentWhatStep {

@BeforeScenario
    public void beforeEachScenario(){
        System.out.println("in before");
    }

@Given("Sample Given")
    public void cleanUp() {
        System.out.println("in given");
    }
@When("Sample When")
    public void action() {
        System.out.println("in When");
    }
@Then("Sample Then")
    public void action() {
        System.out.println("in then");
    }

@AfterScenario
    public void afterEachScenario(){
System.out.println("in After");
  }
}

When i try to run this code the output is

Output:
in given
in When
in Then

2 Answers2

6

This worked to me:

The JBehave API seems to have changed, it seems you now need to add the ScenarioType parameter:

@BeforeScenario(uponType = ScenarioType.ANY)
public void setTheStage() {
    OnStage.setTheStage(new OnlineCast());
}

Source: https://github.com/serenity-bdd/serenity-jbehave/issues/117

Juan Uribe
  • 573
  • 4
  • 5
0

JBehave determines Scenario by your .story file. Chances are you either did not define scenarios in your story file or there is a syntax error and it's being ignored. post your story file here.

Bill Hileman
  • 2,798
  • 2
  • 17
  • 24