在JBehave中,可以在Step級別添加BeforeStory或AfterStory註釋。因此,如果有多個帶有BeforeStory註釋的Steps類,那麼所有那些BeforeStory註釋的方法將在每個故事開始之前執行(不需要)。如何在故事文件中添加JBehave BeforeStory AfterStory
在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
感謝。