Skip to content

Commit 307061c

Browse files
committed
fix: count skipped tests in accuracy executions
1 parent d894941 commit 307061c

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ v3.6.1
66

77
*Release date: In development*
88

9+
- Fix accuracy tag to exclude skipped executions from total executions count
10+
911
v3.6.0
1012
------
1113

toolium/utils/ai_utils/accuracy.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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,31 @@ 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"\nACCURACY 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)")
117127

118128
# Set final scenario status
119129
if has_passed:

0 commit comments

Comments
 (0)