102102
103103all_logs = {}
104104all_logs_json , json_log_cond = [], False
105+ zeuz_tc_run_comment = []
105106tc_error_logs = []
106107all_logs_count = 0
107108all_logs_list = []
@@ -442,6 +443,23 @@ def Result_Analyzer(sTestStepReturnStatus, temp_q):
442443
443444report_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
446464def 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