【发布时间】:2016-03-31 13:27:20
【问题描述】:
尽管我已经编写单元测试 20 多年了,但我是 Gherkin 的新手,并且被赋予了为 .feature 文件实现故事的任务,该文件简化为以下内容:
Scenario: a
Given that the app is open
When I open a certain dialog
Then it has a thing somewhere
Scenario: b
Given that the dialog from 'a' is open...
# Imagine here a long chain of scenarios, each depending on the previous
Scenario: n
Given that the previous 'n' steps have all completed....
也就是说,一长串场景,每个场景都取决于其前身配置的系统状态。
对于习惯于单元测试的人来说,这感觉不对 - 但这些场景不会被拆分并单独运行。
这里的最佳做法是什么?
我应该改写成一个很长的场景吗?
我已经在使用“页面对象”来将我的大部分代码排除在步骤定义之外——我是否应该将步骤编码为单个调用,以便在以后的场景中重复使用?
我正在用 Javascript 运行 Cucumber。
【问题讨论】:
标签: javascript cucumber gherkin cucumberjs