diff --git a/Framework/Built_In_Automation/Sequential_Actions/action_declarations/utility.py b/Framework/Built_In_Automation/Sequential_Actions/action_declarations/utility.py index bde0182c..c0a6b7b3 100644 --- a/Framework/Built_In_Automation/Sequential_Actions/action_declarations/utility.py +++ b/Framework/Built_In_Automation/Sequential_Actions/action_declarations/utility.py @@ -22,6 +22,7 @@ { "name": "log 3", "function": "Add_Log", "screenshot": "none" }, { "name": "log 1", "function": "Add_Log", "screenshot": "none" }, { "name": "show log", "function": "Show_Log", "screenshot": "none" }, + { "name": "custom comment", "function": "custom_comment", "screenshot": "none" }, { "name": "download and unzip", "function": "Download_File_and_Unzip", "screenshot": "none" }, { "name": "take screen shot", "function": "TakeScreenShot", "screenshot": "none" }, { "name": "change ini value", "function": "Change_Value_ini", "screenshot": "none" }, diff --git a/Framework/Utilities/CommonUtil.py b/Framework/Utilities/CommonUtil.py index b68c3df7..2edf195f 100644 --- a/Framework/Utilities/CommonUtil.py +++ b/Framework/Utilities/CommonUtil.py @@ -102,6 +102,7 @@ all_logs = {} all_logs_json, json_log_cond = [], False +zeuz_tc_run_comment = [] tc_error_logs = [] all_logs_count = 0 all_logs_list = [] @@ -442,6 +443,23 @@ def Result_Analyzer(sTestStepReturnStatus, temp_q): report_json_time = 0.0 +def construct_commment_string(original_log, operations): + result = [] + final_comment = "" + for op_dict in operations: + op = op_dict['op'] + comment = op_dict['comment'] + + if op == 'overwrite': + result = [comment] # Clear the list and add the new comment + elif op == 'append': + result.append(comment) # Append the comment + elif op == 'prepend': + result.insert(0, comment) # Prepend the comment + + final_comment = '\n'.join(result) + '\n\n' + original_log + return final_comment.strip() + def CreateJsonReport(logs=None, stepInfo=None, TCInfo=None, setInfo=None): try: @@ -451,7 +469,7 @@ def CreateJsonReport(logs=None, stepInfo=None, TCInfo=None, setInfo=None): return elif upload_on_fail and rerun_on_fail and not rerunning_on_fail and logs: return - global all_logs_json, report_json_time, tc_error_logs, passed_after_rerun + global all_logs_json, report_json_time, tc_error_logs, passed_after_rerun, zeuz_tc_run_comment start = time.perf_counter() if logs or stepInfo or TCInfo or setInfo: log_id = ConfigModule.get_config_value("sectionOne", "sTestStepExecLogId", temp_config) @@ -484,8 +502,12 @@ def CreateJsonReport(logs=None, stepInfo=None, TCInfo=None, setInfo=None): elif passed_after_rerun: fail_reason_str = "** Test case Failed on first run but Passed when Rerun **" passed_after_rerun = False - testcase_info["execution_detail"]["failreason"] = fail_reason_str + + # Add custom comment with fail_reason_str + fail_reason_comment = construct_commment_string(fail_reason_str, zeuz_tc_run_comment) + testcase_info["execution_detail"]["failreason"] = fail_reason_comment tc_error_logs = [] + zeuz_tc_run_comment = [] return if step_id == "none": return