在 JBehave 中,可以在 Step 级别添加 BeforeStory 或 AfterStory 注释。因此,如果有多个带有 BeforeStory 注释的 Steps 类,则所有那些带有 BeforeStory 注释的方法都将在每个故事开始之前执行(这不是必需的)。
在 JUnit 中,我们可以根据需要在测试类中分别添加或保留 BeforeClass 或 Before。所以我需要一种在故事级别添加 BeforeStory 或 AfterStory 的方法,就像 JUnit 测试类一样。
有没有办法在故事文件中添加 BeforeStory 作为生命周期?或任何替代解决方案?
以下示例仅显示在生命周期中添加 Before。
http://jbehave.org/reference/stable/story-syntax.html
Lifecycle:
Before:
Given a step that is executed before each scenario
After:
Outcome: ANY
Given a step that is executed after each scenario regardless of outcome
Outcome: SUCCESS
Given a step that is executed after each successful scenario
Outcome: FAILURE
Given a step that is executed after each failed scenario
谢谢。