在哪里测试 Cucumber 功能中的链接?
假设我将我的黄瓜功能安排在这样的文件中:
features/
├── add_project.feature
├── list_projects.feature
在我的应用程序中,我可以在其中列出所有项目的页面上,我还有一个链接指向可以在其中创建新项目的页面。我想用以下场景测试该链接:
Scenario: Link to create page is visible
Given I am logged in as a staff member
When I go to the projects page
Then I should see a link to the create a project page
现在我的困境:我将该场景放在哪里?
- 将场景放入
list_projects.feature
中。- +链接位于项目列表页面
- - 当我对列表项目功能感兴趣时,我不想阅读有关如何添加项目的信息
- 将场景放入
add_projects.feature
中。- + 当我阅读此功能的描述时,我也对用户如何使用该功能感兴趣
- +如果我有多个指向该功能的链接,它们都会聚集在一个地方
- - 功能和控制器的基本一对一映射被破坏,对我来说,这感觉侵犯了另一个测试的责任
- 。将场景完全放在其他地方。
- 我不知道在哪里:-)
我确信人们以前遇到过这个问题,我想为应用程序建立一个指南,现在两种样式都可以找到,这使得维护变得更加困难。有什么意见可以告诉我你是如何做到的以及为什么吗?
Assume that I arranged my cucumber features in files like that:
features/
├── add_project.feature
├── list_projects.feature
In my application on the page where I can list all projects I also have a link that points to the page where I can create a new project. I want to test that link with the following scenario:
Scenario: Link to create page is visible
Given I am logged in as a staff member
When I go to the projects page
Then I should see a link to the create a project page
Now my dilemma: Where do I put this scenario?
- Put the scenario into
list_projects.feature
.- + The link is on the list projects page
- - When I am interested in the list projects feature I don't want to read about how I am adding projects
- Put the scenario into
add_projects.feature
.- + When I read the description of this feature I am also interested how users are going to get to that feature
- + If I have multiple links to that functionality they all are gathered in one place
- - The basic 1-on-1 mapping of feature and controller is broken, to me it feels that this is intruding another test's responsibility
- Put the scenario somewhere else altogether.
- I have no idea where :-)
I am sure people have faced this problem before and I want to establish a guideline for the application, right now both styles can be found which makes it harder to maintain. Any input how you did it and why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会将这种行为包含在 add_projects.feature 中。
尽管 Cucumber 的内置生成器似乎鼓励每个控制器映射一个功能,但这通常不是安排事物的最佳方式,因此不必担心违反该约定。
I would include that behaviour in the add_projects.feature
Although Cucumber's built-in generators seem to encourage the mapping of one feature per controller, this often isn't the best way to arrange things so don't worry about breaking that convention.