我是JBheave和Hive框架的新手。
在探索Q& A存储库时,我碰巧看到以下短语来自对问题的正确答案之一, -
我所看到的 - 并且应该设置/清除数据对象 使用@ BeforeScenario / @ AfterScenario方法。
目前我正在撰写测试故事。然而,没有进一步进入步骤。
从JBehave产品网站,我得到以下示例测试故事。考虑到我从StackOverFlow的Q& A回购中插入的短语,我有问题。
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
Scenario: Another scenario exploring different combination of events
Given a [precondition]
When a negative event occurs
Then a the outcome should [be-captured]
Examples:
|precondition|be-captured|
|abc|be captured |
|xyz|not be captured|
我可以看到与之前的@ BeforeScenario / @ AfterScenario相同的内容。
我在这里有问题。我是否可以在测试故事中的特定Given
之前和之后写Scenario:
。
并且Scenario:
输出对测试故事中的连续Scenario:
开放。
答案 0 :(得分:7)
@ BeforeScenario / @ AfterScenario注释和生命周期:前/后步骤之间存在一些差异
Lifecycle:
Before:
Given a step that is executed before each scenario with some parameter = 2
答案 1 :(得分:-2)
JBehave用于数据挖掘。它使用测试驱动开发,TDD。我们称之为步骤。 BDD - 行为驱动开发,它产生该框架的挖掘功能,注入任何高级语言。
回答问题, - 在测试故事中,如果我们将Scenario
放在两个then
语句的中间,它会清除缓冲区,因为它是一个新场景。这种方式Given
子句数据集按原样应用,而非隐含。这种方式Given
子句值被采用。对于新Scenario
,仅设置Lifecycle
先决条件仅适用于之前和之后。