-1

I have to test the creation of a product in different countries by a BDD approach. I used cucumber scenario outline.

I have to mention that currency is not mandatory for the creation, it is linked to the country.

I wrote the following test:

Scenario outline: I am able to create a product in different countries
Given a product that costs <price> in <country>
When I create this product
Then the price is <price>
And the currency is <currency>
Examples:
| country | price | currency |
| England | 3     | Pound    |
| Spain   | 32    | Euro     |

A colleague wrote this one:

Scenario outline: I am able to create a product in different countries
Given a product that costs <price> in <country>
When I create this product
Then the price is <price>
And the currency is Pound if country is England
And the currency is Euro if country is Spain
Examples:
| country | price |
| England | 3     |
| Spain   | 32    |

What is the best practice ?

Thanks in advance.

VIJ
  • 1
  • 1

1 Answers1

0

First of all avoid scenario outlines. What they do is condense step definitions and this tends to hide the different things you should be exploring.

Secondly try and be clearer about what you are doing. From what I've read you could be saying

  • A person in one country should be able to create products for other countries

or

  • Users from different countries should be able to create products

or

  • I want to create a product that can be sold in many different countries with many different currencies

These things seem to me to be

  1. Equally valid
  2. Something that you may or may not want to do.

The whole reason for writing scenarios is not to drive tests, its to find out WHAT you want to do and WHY its important, and to express that clearly and without ambiguity.

So for me both of these scenarios are very far from best practice because they are ambiguous and they lack insight into the WHAT and the WHY.

diabolist
  • 3,990
  • 1
  • 11
  • 15