我有一个功能(.feature文件)在黄瓜工作正常.
功能中所有场景的背景仅设置用户,然后以管理员身份登录,例如
Background:
Given I am logged in as a supervisor with an existing supervisee
...loads of scenarios
Run Code Online (Sandbox Code Playgroud)
但是,无论您是以管理员还是以用户身份登录,应用程序的设计/目标都已更改,并且相同的方案应该都可以正常工作.对于大多数应用程序的其余部分而言,情况并非如此,其中设计对于主管/用户来说是不对称的.
是否有任何理智的方法来避免复制和粘贴具有不同背景的整个功能文件?似乎没有一种方法可以参数化背景(例如,使用Either:Or:节),或者另外一种方法来引入具有大量场景的外部文件.想法?
Background:
Given I am logged in as an existing supervisee
...same loads of scenarios
Run Code Online (Sandbox Code Playgroud)
这是一些幻想小黄瓜语法(不存在)
Background Outline:
Given I am logged in as a <user>
Backgrounds:
| user |
| supervisor with an existing supervisee |
| an existing supervisee |
...loads of scenarios
Run Code Online (Sandbox Code Playgroud)
另外,不同的幻想Gherkin语法:
Background:
Given I am logged in as an existing supervisee
Include Scenarios:
supervisor.features
Run Code Online (Sandbox Code Playgroud)
小智 6
如果是我,我只会吸收重复:
http://dannorth.net/2008/06/30/let-your-examples-flow/
另一种方法是在功能上使用一个标记,指示您要针对两个用户组运行方案。然后使用 Around 钩子运行场景两次,对每种类型的用户运行一次。
我们之前已经讨论过背景大纲之类的东西,但我们得出的结论是,实现它不值得额外的复杂性。
| 归档时间: |
|
| 查看次数: |
15961 次 |
| 最近记录: |