之前/之后的场景在 jbehave serenity BDD 中不起作用

Jas*_*nda 0 java jbehave serenity-bdd

之前/之后的场景在 jbehave serenity BDD serenity.version 1.2.3-rc.5 serenity.jbehave.version 1.21.0 中不起作用

例如

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");
  }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试运行此代码时,输​​出是

Output:
in given
in When
in Then
Run Code Online (Sandbox Code Playgroud)

Jua*_*ibe 6

这对我有用:

JBehave API 似乎发生了变化,现在您似乎需要添加 ScenarioType 参数:

@BeforeScenario(uponType = ScenarioType.ANY)
public void setTheStage() {
    OnStage.setTheStage(new OnlineCast());
}
Run Code Online (Sandbox Code Playgroud)

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