diff --git a/Framework/Built_In_Automation/Built_In_Utility/CrossPlatform/BuiltInUtilityFunction.py b/Framework/Built_In_Automation/Built_In_Utility/CrossPlatform/BuiltInUtilityFunction.py index 8e35b4eb6..1d7ac5bdf 100644 --- a/Framework/Built_In_Automation/Built_In_Utility/CrossPlatform/BuiltInUtilityFunction.py +++ b/Framework/Built_In_Automation/Built_In_Utility/CrossPlatform/BuiltInUtilityFunction.py @@ -1522,6 +1522,27 @@ def Add_Log(step_data): except Exception: return CommonUtil.Exception_Handler(sys.exc_info()) + +@logger +def custom_comment(step_data): + sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME + operation = "append" + custom_comment = None + for left,mid,right in step_data: + left = left.lower().strip() + mid = mid.lower().strip() + if left == "operation": + operation = right.lower().strip() + if left == "custom comment": + custom_comment = right.strip() + + if custom_comment == None: + CommonUtil.ExecLog(sModuleInfo, "Custom comment needs to be provided", 3) + return "zeuz_failed" + + CommonUtil.zeuz_tc_run_comment.append({"op":operation, "comment": custom_comment}) + return "passed" + @logger def Show_Log(step_data): try: 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 46cc67a17..bfed69edf 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 3e8af15b4..c4fc87850 100644 --- a/Framework/Utilities/CommonUtil.py +++ b/Framework/Utilities/CommonUtil.py @@ -97,6 +97,7 @@ all_logs = {} all_logs_json, json_log_cond = [], False +zeuz_tc_run_comment = [] tc_error_logs = [] all_logs_count = 0 all_logs_list = [] @@ -460,6 +461,23 @@ def node_manager_json(data): ) 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: @@ -469,7 +487,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) @@ -502,8 +520,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