You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I do execute some code if a step fails. For this in environment.py in def after_step(context, step): I just check if step.status == "failed":
If Context.execute_steps is used the code is executed twice because both steps are returned as failed steps. The origin step and the step which was called by the origin step. Is it possible to somehow only get the origin step status and to omit the step which was called.
Eventually the aim is to execute the code only once and not twice.
The text was updated successfully, but these errors were encountered:
The theoretical case is even worse. Instead of 2 levels (caller and callee), you can have multiple nested levels of ctx.execute_steps() instead of only one.
Currently, I am not aware of an easy mechanism to detect on which side you are are.
I need to look into that.
UNTIL THEN:
You can inspect the stack-frame and make decisions based on that (low-level)
You can add an attribute(s) to the Context object that helps you if the step was already handled (or what error handling strategy you use). You will need to add this attribute (if not already present) before you call ctx.execute_steps() or use a Python ContextManager (enter/exit) to help you.
NOTES:
The outer failing step that calls ctx.execute_steps() is the primary interesting failing step for the user/test-runner. The inner failing steps is for diagnostics to understand why the outer step failed.
Thanks for your hints. What I did the time being. May be some hack, but it works so far ...
before_scenariao I create a step_counter = 0 , before_step I add 1 and after step I reduce by 1. I am only interested in the steps which have step_counter ==1 On after_scenario the step_counter should be == 0 again.
Since I do not really need the diagnostics this works quite well so far. I only need the objects where the step fails. Since in the failing step I do write them in the context I have them available.
related to #983
I do execute some code if a step fails. For this in environment.py in
def after_step(context, step):
I just checkif step.status == "failed":
If Context.execute_steps is used the code is executed twice because both steps are returned as failed steps. The origin step and the step which was called by the origin step. Is it possible to somehow only get the origin step status and to omit the step which was called.
Eventually the aim is to execute the code only once and not twice.
The text was updated successfully, but these errors were encountered: