【发布时间】: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
当执行来验证用户是否处于活动状态(在我的示例中,用户未处于活动状态)时,我希望执行停止并将报告生成为失败的场景。该怎么做?
【问题讨论】:
我在 JBehave 中有以下示例
Given user is super user
Given user is active
When user buys 10 items
Then apply 10% discount
当执行来验证用户是否处于活动状态(在我的示例中,用户未处于活动状态)时,我希望执行停止并将报告生成为失败的场景。该怎么做?
【问题讨论】:
你使用断言:
@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,它会有所不同,语法也可能会有所不同。
【讨论】: