Skip to content

Commit 2bf67e7

Browse files
committed
custom run comment action
1 parent b0eacf0 commit 2bf67e7

3 files changed

Lines changed: 46 additions & 2 deletions

File tree

Framework/Built_In_Automation/Built_In_Utility/CrossPlatform/BuiltInUtilityFunction.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,27 @@ def Add_Log(step_data):
15221522
except Exception:
15231523
return CommonUtil.Exception_Handler(sys.exc_info())
15241524

1525+
1526+
@logger
1527+
def custom_comment(step_data):
1528+
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
1529+
operation = "append"
1530+
custom_comment = None
1531+
for left,mid,right in step_data:
1532+
left = left.lower().strip()
1533+
mid = mid.lower().strip()
1534+
if left == "operation":
1535+
operation = right.lower().strip()
1536+
if left == "custom comment":
1537+
custom_comment = right.strip()
1538+
1539+
if custom_comment == None:
1540+
CommonUtil.ExecLog(sModuleInfo, "Custom comment needs to be provided", 3)
1541+
return "zeuz_failed"
1542+
1543+
CommonUtil.zeuz_tc_run_comment.append({"op":operation, "comment": custom_comment})
1544+
return "passed"
1545+
15251546
@logger
15261547
def Show_Log(step_data):
15271548
try:

Framework/Built_In_Automation/Sequential_Actions/action_declarations/utility.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
{ "name": "log 3", "function": "Add_Log", "screenshot": "none" },
2323
{ "name": "log 1", "function": "Add_Log", "screenshot": "none" },
2424
{ "name": "show log", "function": "Show_Log", "screenshot": "none" },
25+
{ "name": "custom comment", "function": "custom_comment", "screenshot": "none" },
2526
{ "name": "download and unzip", "function": "Download_File_and_Unzip", "screenshot": "none" },
2627
{ "name": "take screen shot", "function": "TakeScreenShot", "screenshot": "none" },
2728
{ "name": "change ini value", "function": "Change_Value_ini", "screenshot": "none" },

Framework/Utilities/CommonUtil.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797

9898
all_logs = {}
9999
all_logs_json, json_log_cond = [], False
100+
zeuz_tc_run_comment = []
100101
tc_error_logs = []
101102
all_logs_count = 0
102103
all_logs_list = []
@@ -460,6 +461,23 @@ def node_manager_json(data):
460461
)
461462
report_json_time = 0.0
462463

464+
def construct_commment_string(original_log, operations):
465+
result = []
466+
final_comment = ""
467+
for op_dict in operations:
468+
op = op_dict['op']
469+
comment = op_dict['comment']
470+
471+
if op == 'overwrite':
472+
result = [comment] # Clear the list and add the new comment
473+
elif op == 'append':
474+
result.append(comment) # Append the comment
475+
elif op == 'prepend':
476+
result.insert(0, comment) # Prepend the comment
477+
478+
final_comment = '\n'.join(result) + '\n\n' + original_log
479+
return final_comment.strip()
480+
463481

464482
def CreateJsonReport(logs=None, stepInfo=None, TCInfo=None, setInfo=None):
465483
try:
@@ -469,7 +487,7 @@ def CreateJsonReport(logs=None, stepInfo=None, TCInfo=None, setInfo=None):
469487
return
470488
elif upload_on_fail and rerun_on_fail and not rerunning_on_fail and logs:
471489
return
472-
global all_logs_json, report_json_time, tc_error_logs, passed_after_rerun
490+
global all_logs_json, report_json_time, tc_error_logs, passed_after_rerun, zeuz_tc_run_comment
473491
start = time.perf_counter()
474492
if logs or stepInfo or TCInfo or setInfo:
475493
log_id = ConfigModule.get_config_value("sectionOne", "sTestStepExecLogId", temp_config)
@@ -502,8 +520,12 @@ def CreateJsonReport(logs=None, stepInfo=None, TCInfo=None, setInfo=None):
502520
elif passed_after_rerun:
503521
fail_reason_str = "** Test case Failed on first run but Passed when Rerun **"
504522
passed_after_rerun = False
505-
testcase_info["execution_detail"]["failreason"] = fail_reason_str
523+
524+
# Add custom comment with fail_reason_str
525+
fail_reason_comment = construct_commment_string(fail_reason_str, zeuz_tc_run_comment)
526+
testcase_info["execution_detail"]["failreason"] = fail_reason_comment
506527
tc_error_logs = []
528+
zeuz_tc_run_comment = []
507529
return
508530
if step_id == "none":
509531
return

0 commit comments

Comments
 (0)