我正在使用Jbehave自动化我的测试。
我使用了某些注释,现在我想在执行故事之前进行某些设置。
例如
如果我有5个用户故事,那么我应该有5个@before故事注释,它将执行不同的任务。
任何人都可以指导我如何实现这一目标?
我进行了Google搜索,但没有得到正确的解决方案。
记住它是关于@BeforeStory而不是@BeforeStories。
先谢谢
阿赫亚!
答案 0 :(得分:0)
使用@BeforeStory注释无法完成,因为在每个故事之前都会执行使用此注释注释的方法 - 对于所有已执行的故事。
但是,您可以在故事中使用lifecycle before
步骤,请查看this示例:
A story is a collection of scenarios
Narrative:
In order to communicate effectively to the business some functionality
As a development team
I want to use Behaviour-Driven Development
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
Scenario: A scenario is a collection of executable steps of different type
Given step represents a precondition to an event
When step represents the occurrence of the event
Then step represents the outcome of the event
请注意Lifecycle: Before:
个关键字:
Lifecycle:
Before:
Given a step that is executed before each scenario
这些关键字旁边的given
步骤将在本故事中的每个场景之前执行 - 但仅适用于此故事中的场景,而不是其他故事中的场景。