pytest-bdd icon indicating copy to clipboard operation
pytest-bdd copied to clipboard

Support asterisks as continuation steps on par with And and But

Open Artalus opened this issue 2 years ago • 0 comments
trafficstars

Gherkin Documentation mentions you can uses * (asterisk) to describe lists of things, same way as with And steps:

Scenario: All done
  Given I am out shopping
  * I have eggs
  * I have milk
  * I have butter
  When I check my list
  Then I don't need anything

Dunno if anybody actually needs such feature - since search for asterisk did not yield anything neither in PRs nor Issues. But since the change is literally 1 line of code, I thought I might propose it just as well and see what happens :smile: Not sure if the place for testing it is right (tests/feature/test_steps.py) or if it should be done someplace else tho.


One (perhaps controversial) use-case that comes to mind, which would benefit from asterisks, is something like this:

Given foo '1' is barred
And   foo '2' is barred

When Alice bazzes foo '2'

Then we observe foo '1':
* its 'top' is 'kek'
* ...

Then we observe foo '2':
* its 'top' is 'peck'
* ...

It could be written as Then we observe ... and its ... already, and would definitely be better with something like For foo ... its ... - but I think asterisks might still be a step in right direction.

Artalus avatar Apr 29 '23 12:04 Artalus