Skip to content
4 changes: 2 additions & 2 deletions pytest_bdd/cucumber_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def add_options(parser):
"--cucumberjson-expanded",
"--cucumber-json-expanded",
action="store_true",
dest="expand",
dest="cucumber_json_expanded",
default=False,
help="expand scenario outlines into scenarios and fill in the step names",
)
Expand All @@ -42,7 +42,7 @@ def configure(config):
cucumber_json_path = config.option.cucumber_json_path
# prevent opening json log on slave nodes (xdist)
if cucumber_json_path and not hasattr(config, "slaveinput"):
config._bddcucumberjson = LogBDDCucumberJSON(cucumber_json_path, expand=config.option.expand)
config._bddcucumberjson = LogBDDCucumberJSON(cucumber_json_path, expand=config.option.cucumber_json_expanded)
config.pluginmanager.register(config._bddcucumberjson)


Expand Down
8 changes: 4 additions & 4 deletions pytest_bdd/gherkin_terminal_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ def add_options(parser):
group._addoption(
"--gherkin-terminal-reporter-expanded",
action="store_true",
dest="expand",
dest="gherkin_expanded",
default=False,
help="expand scenario outlines into scenarios and fill in the step names",
help="enable gherkin output, expand scenario outlines into scenarios and fill in the step names",
)


def configure(config):
if config.option.gherkin_terminal_reporter:
if config.option.gherkin_terminal_reporter or config.option.gherkin_expanded:
# Get the standard terminal reporter plugin and replace it with our
current_reporter = config.pluginmanager.getplugin('terminalreporter')
if current_reporter.__class__ != TerminalReporter:
Expand Down Expand Up @@ -102,7 +102,7 @@ def pytest_runtest_logreport(self, report):
self._tw.write(report.scenario['name'], **scenario_markup)
self._tw.write('\n')
for step in report.scenario['steps']:
if self.config.option.expand:
if self.config.option.gherkin_expanded:
step_name = self._format_step_name(step['name'], **report.scenario['example_kwargs'])
else:
step_name = step['name']
Expand Down
9 changes: 7 additions & 2 deletions tests/feature/gherkin_terminal_reporter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ Feature: Gherkin terminal reporter
When I run tests with --showlocals
Then error traceback contains local variable descriptions

Scenario: Should step parameters be replaced by their values
Scenario Outline: Should step parameters be replaced by their values
Given there is gherkin scenario outline implemented
When I run tests with step expanded mode
When I run tests with <gherkin_options>
Then output must contain parameters values

Examples:
| gherkin_options |
| --gherkin-terminal-reporter-expanded |
| --gherkin-terminal-reporter --gherkin-terminal-reporter-expanded |
9 changes: 4 additions & 5 deletions tests/feature/test_gherkin_terminal_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,12 @@ def run_tests_with_very_verbose_mode(testdir, test_execution):
test_execution['gherkin'] = testdir.runpytest('--gherkin-terminal-reporter', '-vv')


@when("I run tests with step expanded mode")
def run_tests_with_step_expanded_mode(testdir, test_execution):
@when("I run tests with <gherkin_options>")
def run_tests_with_step_expanded_mode(testdir, test_execution, gherkin_options):
test_execution['regular'] = testdir.runpytest('-vv')
options = gherkin_options + ' -vv'
test_execution['gherkin'] = testdir.runpytest(
'--gherkin-terminal-reporter',
'--gherkin-terminal-reporter-expanded',
'-vv',
*options.split()
)


Expand Down