The Importance of “But” in BDD

Some think that “but” is unnecessary, others forbid their use, but its correct use is essential.

David Rodenas PhD

--

The keyword “But” in Gherkin has the same logical function as “And” — it continues the list of conditions or results. It’s purely a matter of readability and narrative flow. And just because of it, for many, seems redundant and useless. Until the point, that some people who have been writing gherkins for years, still find it useless. Yet, it is so important that the standard includes it among its only five step keywords: “Given”, “When”, “Then”, “And”, and “But”. But why?

First, we need to understand why some people do not use them.

The Logical.

“The Logical” sees “And” and “But” in Gherkin as interchangeable. They favor “And” for simplicity and consistency. Their choice balances syntax simplicity with effective communication.

Certainly, both keywords, the “But” and the “And” serve the same functional purpose in Gherkin syntax. They are used to continue a list of preconditions in a “Given” context, actions in a “When” context, or outcomes in a “Then” context. Essentially, they allow for multiple…

--

--

David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.