I am writing a feature which deals with adding multiple items to shopping cart like a typical e-commerce application.
It is something like this -
Scenario: Promotion is applied
Given I select "Bacon" worth "$1"
Given I select "Lettuce" worth "$2"
Given I select "Diet Coke" worth "$5"
Given I select "Bread" worth "$2"
Then "$0.5" promotion should be applied for "Bacon"
Then "$0.0" promotion should be applied for "Lettuce"
Then "$0.5" promotion should be applied for "Diet Coke"
Then "$1.0" promotion should be applied for "Bread"
Then total paid should be "$8"
Needless to say, the stepdefs.js look something like this:
Given(/^I select "([^"]*)" worth "([^"]*)"$/, function (item, price) {
//addToCart
});
etc.
There is another scenario which is similar and adds clothes instead of food items.
If I am using Scenario outline and Examples it turns to this:
Scenario Outline: Promotion is applied
Given I select "<item>" worth "<price>"
Given I select "<item>" worth "<price>"
Given I select "<item>" worth "<price>"
Given I select "<item>" worth "<price>"
Then "<discount>" promotion should be applied for "<item>
Then "<discount>" promotion should be applied for "<item>
Then "<discount>" promotion should be applied for "<item>
Then "<discount>" promotion should be applied for "<item>
Then total paid should be "$8"
Examples:
| item | price | discount |
| "Bacon" | "$1" | 0.5
| "Lettuce" | "$2" | 0.0
| "Diet Coke" | "$5" | 1.0
| "Bread" | "$2" | 0.5
But it runs the test once per row (so four tests are run), what I essentially want is running all of them for one test.
In fact I want to run them as 4 items added for food vs 2 items added for clothes. So,
Scenario Outline: Promotion is applied <type>
Given I select "<item>" worth "<price>"
Then "<discount>" promotion should be applied for "<item>"
Then total paid should be "<total>"
Examples:
type | items & prices & promotion (may be some object like that?) | total
food | [ {"Bacon - $1 - 0.5"}, {"Lettuce - $2 - 0.0"}, {"Diet Coke - $5 - 1.0"}, {"Bread - $2 - 0.5"} ] /*takes an array*/ | $8
clothes | [{"pant - $50 - 10"}, {"shirt - $25 - 5"}] | $60
Is it even possible? How do one achieve that?
Thanks
[EDIT]: This is just an example question, I've removed all complications and this is just a nailed down version. My idea is to get a way to use array of objects in scenarios. Please do not go by the name and numbers mentioned in the question.