diff --git a/pytest_bdd/hooks.py b/pytest_bdd/hooks.py index b3ec01e5..25f4fa42 100644 --- a/pytest_bdd/hooks.py +++ b/pytest_bdd/hooks.py @@ -19,6 +19,11 @@ def pytest_bdd_before_step_call(request, feature, scenario, step, step_func, ste """Called before step function is executed.""" +@pytest.hookspec(firstresult=True) +def pytest_bdd_call_step(request, feature, scenario, step, step_func, step_func_args): + """Call the underlying step.""" + + def pytest_bdd_after_step(request, feature, scenario, step, step_func, step_func_args): """Called after step function is successfully executed.""" diff --git a/pytest_bdd/plugin.py b/pytest_bdd/plugin.py index 1da65498..af2e8577 100644 --- a/pytest_bdd/plugin.py +++ b/pytest_bdd/plugin.py @@ -70,6 +70,12 @@ def pytest_bdd_before_step(request, feature, scenario, step, step_func): reporting.before_step(request, feature, scenario, step, step_func) +@pytest.mark.trylast +def pytest_bdd_call_step(request, feature, scenario, step, step_func, step_func_args): + step_func(**step_func_args) + return True + + @pytest.mark.tryfirst def pytest_bdd_after_step(request, feature, scenario, step, step_func, step_func_args): reporting.after_step(request, feature, scenario, step, step_func, step_func_args) diff --git a/pytest_bdd/scenario.py b/pytest_bdd/scenario.py index 07a52132..f015634c 100644 --- a/pytest_bdd/scenario.py +++ b/pytest_bdd/scenario.py @@ -134,7 +134,7 @@ def _execute_step_function(request, scenario, step, step_func): request.config.hook.pytest_bdd_before_step_call(**kw) # Execute the step. - step_func(**kwargs) + request.config.hook.pytest_bdd_call_step(**kw) request.config.hook.pytest_bdd_after_step(**kw) except Exception as exception: request.config.hook.pytest_bdd_step_error(exception=exception, **kw)