Skip to content

Commit 38e112e

Browse files
committed
Add test for keyword aliases
1 parent 6805f9c commit 38e112e

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

tests/feature/test_gherkin_terminal_reporter.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,64 @@ def test_scenario_2():
236236
result.stdout.fnmatch_lines("*When I eat {eat} cucumbers".format(**example))
237237
result.stdout.fnmatch_lines("*Then I should have {left} cucumbers".format(**example))
238238
result.stdout.fnmatch_lines("*PASSED")
239+
240+
241+
def test_scenario_alias_keywords_are_accepted(pytester):
242+
"""
243+
Test that aliases for various keywords are accepted and reported correctly.
244+
see https://cucumber.io/docs/gherkin/reference/
245+
"""
246+
pytester.makefile(
247+
".feature",
248+
simple="""
249+
Feature: Simple feature
250+
Scenario: Simple scenario
251+
Given I have a <tag>
252+
Then pass
253+
254+
Example: Simple example
255+
Given I have a <tag>
256+
Then pass
257+
258+
Scenario Outline: Outlined scenario
259+
Given I have a templated <foo>
260+
Then pass
261+
262+
Examples:
263+
| foo |
264+
| bar |
265+
266+
Scenario Template: Templated scenario
267+
Given I have a templated <foo>
268+
Then pass
269+
270+
Scenarios:
271+
| foo |
272+
| bar |
273+
""",
274+
)
275+
pytester.makepyfile(
276+
"""
277+
from pytest_bdd import scenarios, given, then, parsers
278+
279+
scenarios("simple.feature")
280+
281+
@given("I have a <tag>")
282+
def _():
283+
return "tag"
284+
285+
@given(parsers.parse("I have a templated {foo}"))
286+
def _(foo):
287+
return "foo"
288+
289+
@then("pass")
290+
def _():
291+
pass
292+
"""
293+
)
294+
result = pytester.runpytest("--gherkin-terminal-reporter", "-vv")
295+
result.assert_outcomes(passed=4, failed=0)
296+
result.stdout.fnmatch_lines("*Feature: Simple feature*")
297+
result.stdout.fnmatch_lines("*Example: Simple example*")
298+
result.stdout.fnmatch_lines("*Scenario: Simple scenario*")
299+
result.stdout.fnmatch_lines("*Scenario Outline: Outlined scenario*")

0 commit comments

Comments
 (0)