From 15b83ee41b6c000da25a16b85d2a35b9755b9a1f Mon Sep 17 00:00:00 2001 From: Jason Allen Date: Sat, 5 Oct 2024 10:13:54 +0100 Subject: [PATCH] Add changelog entry. Add section to README to exemplify usage. --- CHANGES.rst | 1 + README.rst | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index ebfb239f..b09b608e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,7 @@ Unreleased ---------- - Update documentation to clarify that `--gherkin-terminal-reporter` needs to be used with `-v` or `-vv`. - Drop compatibility with pytest < 7.0.0. +- Continuation of steps using asterisks instead of And/But supported. 8.0.0b1 ---------- diff --git a/README.rst b/README.rst index 5bd1d099..c0814eac 100644 --- a/README.rst +++ b/README.rst @@ -156,6 +156,55 @@ default author. And there's an article +Using Asterisks in Place of Keywords +------------------------------------ + +To avoid redundancy or unnecessary repetition of keywords +such as "And" or "But" in Gherkin scenarios, +you can use an asterisk (*) as a shorthand. +The asterisk acts as a wildcard, allowing for the same functionality +without repeating the keyword explicitly. +It improves readability by making the steps easier to follow, +especially when the specific keyword does not add value to the scenario's clarity. + +The asterisk will work the same as other step keywords - Given, When, Then - it follows. + +For example: + +.. code-block:: gherkin + + Feature: Resource owner + Scenario: I'm the author + Given I'm an author + * I have an article + * I have a pen + + +.. code-block:: python + + from pytest_bdd import given + + @given("I'm an author") + def _(): + pass + + @given("I have an article") + def _(): + pass + + @given("I have a pen") + def _(): + pass + + +In the scenario above, the asterisk (*) replaces the And or Given keywords. +This allows for cleaner scenarios while still linking related steps together in the context of the scenario. + +This approach is particularly useful when you have a series of steps +that do not require explicitly stating whether they are part of the "Given", "When", or "Then" context +but are part of the logical flow of the scenario. + + Step arguments --------------