Good day,
I have been thinking about the substance of describing features (Gherkin syntax) and cannot find the best answer.
Two examples of the same scenario:
Scenario: Creation of a new task
Given I see the button for the creation of a new task
When I click the button in order to create a new task
Then I see the task editor
Scenario: Creation of a new task
Given I see the button "Create task"
When I click the button "Create task"
Then I see page "Task editor" has been opened
I see the main differences:
The first variant is interface-independent. But, you MUST use a selector or similar to find the exact element, but then you can change everything in the interface, and these tests will not fail (as the second variant).
The first variant is NOT declarative. In general, you cannot reuse it for describing any OTHER interface behavior.
For my taste, the second variant much more simple for understanding what is going on in the scenario.
I think, the second variant is much more flexible and allow you to write scenarios MUCH faster, but at the same time has problems:
You MUST include interface data in the scenarios. It is not a good practice. But by this (flexibility), you may describe anything to test (as visible data, for example), so such tests are much more accurate, and provide higher quality.
Any time when you change an interface, you need to fix your tests.
So, can you tell, what do you think about it?
I think that flexibility, speed, quality, and readability (the second variant) are much better than the first variant (which have nothing, except readability and "stability"?), but I am not sure. Yes, you put some data in scenarios, but you almost NEVER change them, and even if you will change it, it may be fixed in seconds/minutes.
What do you use in your projects, and why?
And, the main question is, which variant is better?
Tell your thoughts, please.
In our current company (dozens services, enterprise grade, written in BDD) we started with first variant.
Scenario: Creation of a new task
Given I see the button for the creation of a new task
When I click the button in order to create a new task
Then I see the task editor
We decided that is more business oriented, more descriptive and more clear.
But after few months real life shows us that second version is much more flexible, and working with this version makes less problems.
Finally we rewrote all scenarios to second version
Scenario: Creation of a new task
Given I see the button "Create task"
When I click the button "Create task"
Then I see page "Task editor" has been opened
an we are happy using this till now.
Summary: Based on several months of using both versions, in written in team, with BDD style (tests first) enterprise software: second version win. Even if with BDD theory first version might looks better.