Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
26 changes: 24 additions & 2 deletions Framework/Utilities/CommonUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down