Skip to content

Commit 43d11dc

Browse files
Merge pull request #489 from AutomationSolutionz/custom-run-comment
Custom Run Comment to control within testcases
2 parents 2b81dff + 855398a commit 43d11dc

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

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
@@ -102,6 +102,7 @@
102102

103103
all_logs = {}
104104
all_logs_json, json_log_cond = [], False
105+
zeuz_tc_run_comment = []
105106
tc_error_logs = []
106107
all_logs_count = 0
107108
all_logs_list = []
@@ -442,6 +443,23 @@ def Result_Analyzer(sTestStepReturnStatus, temp_q):
442443

443444
report_json_time = 0.0
444445

446+
def construct_commment_string(original_log, operations):
447+
result = []
448+
final_comment = ""
449+
for op_dict in operations:
450+
op = op_dict['op']
451+
comment = op_dict['comment']
452+
453+
if op == 'overwrite':
454+
result = [comment] # Clear the list and add the new comment
455+
elif op == 'append':
456+
result.append(comment) # Append the comment
457+
elif op == 'prepend':
458+
result.insert(0, comment) # Prepend the comment
459+
460+
final_comment = '\n'.join(result) + '\n\n' + original_log
461+
return final_comment.strip()
462+
445463

446464
def CreateJsonReport(logs=None, stepInfo=None, TCInfo=None, setInfo=None):
447465
try:
@@ -451,7 +469,7 @@ def CreateJsonReport(logs=None, stepInfo=None, TCInfo=None, setInfo=None):
451469
return
452470
elif upload_on_fail and rerun_on_fail and not rerunning_on_fail and logs:
453471
return
454-
global all_logs_json, report_json_time, tc_error_logs, passed_after_rerun
472+
global all_logs_json, report_json_time, tc_error_logs, passed_after_rerun, zeuz_tc_run_comment
455473
start = time.perf_counter()
456474
if logs or stepInfo or TCInfo or setInfo:
457475
log_id = ConfigModule.get_config_value("sectionOne", "sTestStepExecLogId", temp_config)
@@ -484,8 +502,12 @@ def CreateJsonReport(logs=None, stepInfo=None, TCInfo=None, setInfo=None):
484502
elif passed_after_rerun:
485503
fail_reason_str = "** Test case Failed on first run but Passed when Rerun **"
486504
passed_after_rerun = False
487-
testcase_info["execution_detail"]["failreason"] = fail_reason_str
505+
506+
# Add custom comment with fail_reason_str
507+
fail_reason_comment = construct_commment_string(fail_reason_str, zeuz_tc_run_comment)
508+
testcase_info["execution_detail"]["failreason"] = fail_reason_comment
488509
tc_error_logs = []
510+
zeuz_tc_run_comment = []
489511
return
490512
if step_id == "none":
491513
return

0 commit comments

Comments
 (0)