简体   繁体   English

场景之前/之后无法在jbehave serenity BDD中工作

[英]Before/After Scenario not working in jbehave serenity BDD

Before/After Scenario not working in jbehave serenity BDD serenity.version 1.2.3-rc.5 serenity.jbehave.version 1.21.0 场景之前/之后无法在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

This worked to me: 这对我有用:

The JBehave API seems to have changed, it seems you now need to add the ScenarioType parameter: JBehave API似乎已更改,看来您现在需要添加ScenarioType参数:

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

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

JBehave determines Scenario by your .story file. JBehave通过您的.story文件确定方案。 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. 在此处发布您的故事文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM