I am trying to understand how I can group scenarios together logically. Lets say I have a Feature such as viewing cart after filling an order.
Given I am on the items page
When I click shop button
And I add an apple
And I add a bananna
When I click next
Then I should see my cart summary
The closest thing to what you're looking for is background:
Background allows you to add some context to the scenarios in a single feature. A Background is much like a scenario containing a number of steps. The difference is when it is run. The background is run before each of your scenarios but after any of your Before Hooks.
Using this idea, you could do something like:
Feature: Shopping cart testing Background: Given I am on the items page When I click shop button And I add an apple And I add a bananna And I click next Scenario: Check shopping cart is present Then I should see my cart summary Scenario: I should be able to remove an item When I remove an item Then the shopping cart should have one item
Note that both scenarios are independent though they share a common background (a set of initial steps).
I usually use Background's in my tests though I only use Givens. From my point of view, a background should present a state and not actions performed by the user (though this is just my opinion). I know that there are tests out there using
when in backgrounds and it's an allowed practice.
Hope it helps.