【问题标题】:how to stop execution of following steps if a preceding step fails in Jbehave如果前面的步骤在 Jbehave 中失败,如何停止执行后面的步骤
【发布时间】:2018-11-17 10:05:48
【问题描述】:

我在 JBehave 中有以下示例

Given user is super user
Given user is active
When user buys 10 items
Then apply 10% discount

当执行来验证用户是否处于活动状态(在我的示例中,用户未处于活动状态)时,我希望执行停止并将报告生成为失败的场景。该怎么做?

【问题讨论】:

    标签: bdd jbehave


    【解决方案1】:

    你使用断言:

    @Given("user is active")
    public void givenUserIsActive() {
        Assert.AssertTrue(UserIsActive); // whatever you need to do to test the condition
    }
    

    我没有加载我的 Eclipse,所以我不知道确切的包含文件,但对于 JUnit,我认为它是 org.junit.assert。如果您使用的是 TestNG,它会有所不同,语法也可能会有所不同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-12
      • 2020-05-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多