开发者

Where to test links in cucumber features?

开发者 https://www.devze.com 2023-03-31 09:42 出处:网络
Assume that I arranged my cucumber features in files like that: features/ ├── add_project.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 es开发者_如何学Pythontablish 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号