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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top