@@ -89,7 +89,7 @@ def patch_scenario_with_accuracy(context, scenario, data_key_suffix, accuracy=0.
8989 """
9090 def scenario_run_with_accuracy (context , scenario_run , scenario , * args , ** kwargs ):
9191 # Execute the scenario multiple times and count passed executions
92- passed_executions = 0
92+ passed_executions = skipped_executions = 0
9393 # Copy scenario steps to avoid modifications in each execution, especially when using behave variables
9494 # transformation, like map_param and replace_param methods
9595 orig_steps = deepcopy (scenario .steps )
@@ -99,21 +99,35 @@ def scenario_run_with_accuracy(context, scenario_run, scenario, *args, **kwargs)
9999 # Restore original steps before each execution
100100 scenario .steps = deepcopy (orig_steps )
101101 if not scenario_run (* args , ** kwargs ):
102- passed_executions += 1
103- status = "PASSED"
102+ if scenario .status == Status .skipped :
103+ skipped_executions += 1
104+ status = "SKIPPED"
105+ else :
106+ passed_executions += 1
107+ status = "PASSED"
104108 else :
105109 status = "FAILED"
106110 print (f"ACCURACY SCENARIO { status } : execution { execution + 1 } /{ executions } " )
107111 context .logger .info (f"Accuracy scenario execution { status } ({ execution + 1 } /{ executions } )" )
108112
113+ if executions == skipped_executions :
114+ context .logger .info ("All accuracy scenario executions are skipped" )
115+ return False # Run method returns false when skipped
116+
109117 # Calculate scenario accuracy
110- scenario_accuracy = passed_executions / executions
118+ scenario_accuracy = passed_executions / ( executions - skipped_executions )
111119 has_passed = scenario_accuracy >= accuracy
112120 final_status = 'PASSED' if has_passed else 'FAILED'
113121 print (f"\n ACCURACY SCENARIO { final_status } : { executions } executions,"
114122 f" accuracy { scenario_accuracy } >= { accuracy } " )
115123 final_message = (f"Accuracy scenario { final_status } after { executions } executions with"
116- f" accuracy { scenario_accuracy } >= { accuracy } " )
124+ f" accuracy { scenario_accuracy } >= { accuracy } "
125+ f" ({ passed_executions } passed, { skipped_executions } skipped,"
126+ f" { executions - passed_executions - skipped_executions } failed)" )
127+
128+ # Clean accuracy execution data from context
129+ context .storage .pop ("accuracy_execution_data" , None )
130+ context .storage .pop ("accuracy_execution_index" , None )
117131
118132 # Set final scenario status
119133 if has_passed :
0 commit comments