I'm trying to understand Gherkin, enough that I can separate out the user stories and allow the business expert to write them.
If I have a Background (version 1), a common precondition, why do all my Scenarios get errors telling me "Multiple step definitions match", isn't that the point of Background, to be common for all?
If I have different Given statements (version 1), then shouldn't the When that follows allow the same action, based on different starting positions? Again, the When causes "Multiple step definitions match"
Here is my feature file. Ideally I want Version 1, this is how the business expert is writing them, separate, easy to read but the only way to get this working without "Multiple step definitions match" errors is Version 2, where each When needs to be a combination, more complex, harder to read.
Why can't I use Background with more than 1 Scenario?
These forced changes smell, so what am I doing wrong, what have I missed? I have found hundreds of simple examples, but I feel I am missing some sort of guiding principle of Gherkin. What am I missing?
Feature: Help
When users says help
"As a user
I want the bot to understand me when I ask for help,
In order that I get some guidance, or some idea what to do next"
# Version 1
Background:
Given the user is in conversation with the bot
*// above line causes error*
Scenario: No topic
Given there is no topic
When the user says help
*// above line causes error*
Then the bot responds with a sorry, regretful message
And then asks if the user would like to see a list of available features
Scenario: A valid topic
Given there is a valid topic
When the user says help
*// above line causes error*
Then the bot responds with a confirmation message
And then asks if the user would like to see a list of topic features
# Version 2
# Scenario: All
# Given the user is in conversation with the bot
# When the user says help and there is no topic
# Then the bot responds with a sorry, regretful message
# And then asks if the user would like to see a list of available features
# When the user says help and there is a valid topic
# Then the bot responds with a confirmation message
# And then asks if the user would like to see a list of topic features
Failures:
1) Scenario: No topic # features/help.feature:10
✖ Given the user is in conversation with the bot
Multiple step definitions match:
the user is in conversation with the bot - tests/feature_definitions/help_definition.js:4
the user is in conversation with the bot - tests/feature_definitions/help_definition.js:21
- Given there is no topic # tests/feature_definitions/help_definition.js:7
✖ When the user says help
Multiple step definitions match:
the user says help - tests/feature_definitions/help_definition.js:10
the user says help - tests/feature_definitions/help_definition.js:27
- Then the bot responds with a sorry, regretful message # tests/feature_definitions/help_definition.js:13
- And then asks if the user would like to see a list of available features # tests/feature_definitions/help_definition.js:16
2) Scenario: A valid topic # features/help.feature:16
✖ Given the user is in conversation with the bot
Multiple step definitions match:
the user is in conversation with the bot - tests/feature_definitions/help_definition.js:4
the user is in conversation with the bot - tests/feature_definitions/help_definition.js:21
- Given there is a valid topic # tests/feature_definitions/help_definition.js:24
✖ When the user says help
Multiple step definitions match:
the user says help - tests/feature_definitions/help_definition.js:10
the user says help - tests/feature_definitions/help_definition.js:27
- Then the bot responds with a confirmation message # tests/feature_definitions/help_definition.js:30
- And then asks if the user would like to see a list of topic features # tests/feature_definitions/help_definition.js:33