Skip to content

Commit 15b83ee

Browse files
committed
Add changelog entry.
Add section to README to exemplify usage.
1 parent f189ae4 commit 15b83ee

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Unreleased
55
----------
66
- Update documentation to clarify that `--gherkin-terminal-reporter` needs to be used with `-v` or `-vv`.
77
- Drop compatibility with pytest < 7.0.0.
8+
- Continuation of steps using asterisks instead of And/But supported.
89

910
8.0.0b1
1011
----------

README.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,55 @@ default author.
156156
And there's an article
157157
158158
159+
Using Asterisks in Place of Keywords
160+
------------------------------------
161+
162+
To avoid redundancy or unnecessary repetition of keywords
163+
such as "And" or "But" in Gherkin scenarios,
164+
you can use an asterisk (*) as a shorthand.
165+
The asterisk acts as a wildcard, allowing for the same functionality
166+
without repeating the keyword explicitly.
167+
It improves readability by making the steps easier to follow,
168+
especially when the specific keyword does not add value to the scenario's clarity.
169+
170+
The asterisk will work the same as other step keywords - Given, When, Then - it follows.
171+
172+
For example:
173+
174+
.. code-block:: gherkin
175+
176+
Feature: Resource owner
177+
Scenario: I'm the author
178+
Given I'm an author
179+
* I have an article
180+
* I have a pen
181+
182+
183+
.. code-block:: python
184+
185+
from pytest_bdd import given
186+
187+
@given("I'm an author")
188+
def _():
189+
pass
190+
191+
@given("I have an article")
192+
def _():
193+
pass
194+
195+
@given("I have a pen")
196+
def _():
197+
pass
198+
199+
200+
In the scenario above, the asterisk (*) replaces the And or Given keywords.
201+
This allows for cleaner scenarios while still linking related steps together in the context of the scenario.
202+
203+
This approach is particularly useful when you have a series of steps
204+
that do not require explicitly stating whether they are part of the "Given", "When", or "Then" context
205+
but are part of the logical flow of the scenario.
206+
207+
159208
Step arguments
160209
--------------
161210

0 commit comments

Comments
 (0)