diff --git a/pytest_bdd/cucumber_json.py b/pytest_bdd/cucumber_json.py index 71b9feab..41b8dc4c 100644 --- a/pytest_bdd/cucumber_json.py +++ b/pytest_bdd/cucumber_json.py @@ -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", ) @@ -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) diff --git a/pytest_bdd/gherkin_terminal_reporter.py b/pytest_bdd/gherkin_terminal_reporter.py index 9329b0cb..c045c745 100644 --- a/pytest_bdd/gherkin_terminal_reporter.py +++ b/pytest_bdd/gherkin_terminal_reporter.py @@ -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: @@ -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'] diff --git a/tests/feature/gherkin_terminal_reporter.feature b/tests/feature/gherkin_terminal_reporter.feature index a7ba9f45..5111a139 100644 --- a/tests/feature/gherkin_terminal_reporter.feature +++ b/tests/feature/gherkin_terminal_reporter.feature @@ -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 Then output must contain parameters values + + Examples: + | gherkin_options | + | --gherkin-terminal-reporter-expanded | + | --gherkin-terminal-reporter --gherkin-terminal-reporter-expanded | diff --git a/tests/feature/test_gherkin_terminal_reporter.py b/tests/feature/test_gherkin_terminal_reporter.py index 415c2cc7..2a853310 100644 --- a/tests/feature/test_gherkin_terminal_reporter.py +++ b/tests/feature/test_gherkin_terminal_reporter.py @@ -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 ") +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() )