Jbehave : GivenStories 在结束时执行

Jbehave : GivenStories in the end of execution

我正在使用 GivenStories 来执行位于不同故事中的登录场景。 我想知道是否有一种方法可以使用类似的东西来执行注销故事,该故事也位于与我实际执行的故事不同的故事中。

我知道我可以用@before/after 注释做一些小技巧,但问题是我是否可以执行 "post" 故事

谢谢

基于 jBehave annotation documentation 一个 post 故事步骤可以通过使用 @AfterStory 注释一个步骤 class 方法来实现(或者 @AfterStories 如果你想只在之后执行所有的故事都完成了)。 @AfterStory 方法将执行,无论您的执行故事是否包含相关步骤 class 中的一个步骤(即保证在每个故事之后执行 - 请参阅下文以限制给定故事)。

The @BeforeStory and @AfterStory annotations allow the corresponding methods to be executed before and after each story, either a GivenStory or not:

@AfterStory // equivalent to @AfterStory(uponGivenStory=false)
public void afterStory() {
    // ...
}

@AfterStory(uponGivenStory=true)
public void afterGivenStory() {
    // ...
}

这是我从 jbehave 开发频道得到的答案。

Hi,

there is no such mechanism, but you could:

use the Lifecycle to execute steps (not stories) after the execution of a scenario (executed after each scenario) have a final scenario which invokes the given stories