Skip to content

Commit 56ae875

Browse files
[Add] Skip tc range implement
1 parent 721d5ee commit 56ae875

File tree

3 files changed

+15
-32
lines changed

3 files changed

+15
-32
lines changed

Framework/Built_In_Automation/Sequential_Actions/common_functions.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4370,10 +4370,8 @@ def skip_testcases(data_set):
43704370
skip testcases | common action | 6716-6720
43714371
"""
43724372
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
4373-
43744373
try:
43754374
test_cases = None
4376-
43774375
for left, mid, right in data_set:
43784376
left = left.strip().lower()
43794377
if "skip testcases" in left:
@@ -4388,9 +4386,6 @@ def skip_testcases(data_set):
43884386
else:
43894387
for test_case in test_cases.split(","):
43904388
if '-' in test_case:
4391-
CommonUtil.ExecLog(sModuleInfo, "Range wont work for now. Provide test case name in comma separated way or put 'skip remaining'", 3)
4392-
return "zeuz_failed"
4393-
''' Range wont work for now because only single tc comes from server one by one '''
43944389
range_start, range_end = map(int, test_case.split('-'))
43954390
CommonUtil.skip_testcases[run_id].append(range(range_start, range_end))
43964391
else:

Framework/MainDriverApi.py

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,7 @@ def run_all_test_steps_in_a_test_case(
484484
step_attachment_list.append(attachment_name)
485485
shared.Set_Shared_Variables(attachment_name, path, attachment_var=True)
486486

487-
# loop through the steps
488487
while StepSeq <= Stepscount:
489-
490-
# check if debug step
491488
CommonUtil.custom_step_duration = ""
492489
if debug and debug_steps:
493490
if str(StepSeq) not in debug_steps:
@@ -525,14 +522,12 @@ def run_all_test_steps_in_a_test_case(
525522
CommonUtil.step_index += 1
526523
continue
527524

528-
# get step info
529525
CommonUtil.current_step_name = current_step_name = all_step_info[StepSeq - 1]["step_name"]
530526
CommonUtil.current_step_id = current_step_id = all_step_info[StepSeq - 1]["step_id"]
531527
CommonUtil.current_step_sequence = current_step_sequence = all_step_info[StepSeq - 1]["step_sequence"]
532528

533529
shared.Set_Shared_Variables("zeuz_current_step", all_step_info[StepSeq - 1], print_variable=False, pretty=False)
534530

535-
# add config value
536531
ConfigModule.add_config_value(
537532
"sectionOne",
538533
"sTestStepExecLogId",
@@ -930,7 +925,7 @@ def send_browser_perf_metrics():
930925
send_browser_perf_metrics()
931926

932927

933-
def check_test_skip(all_testcases_info, run_id, tc_num, skip_remaining=True) -> bool:
928+
def check_test_skip(run_id, tc_num, skip_remaining=True) -> bool:
934929
if run_id not in CommonUtil.skip_testcases:
935930
return False
936931
if skip_remaining and 'skip remaining' in CommonUtil.skip_testcases[run_id]:
@@ -940,23 +935,24 @@ def check_test_skip(all_testcases_info, run_id, tc_num, skip_remaining=True) ->
940935
ranges = [i for i in CommonUtil.skip_testcases[run_id] if type(i) == range]
941936
if len(ranges) == 0:
942937
return False
943-
tc_nums = [int(i['testcase_no'].split('-')[-1]) for i in all_testcases_info]
944-
target = tc_nums.index(tc_num)
938+
939+
target = CommonUtil.tc_nums[run_id].index(tc_num)
945940
for rang in ranges:
946-
start = tc_nums.index(rang.start) if rang.start in tc_nums else None
947-
end = tc_nums.index(rang.stop) if rang.stop in tc_nums else None
941+
start = CommonUtil.tc_nums[run_id].index(rang.start) if rang.start in CommonUtil.tc_nums[run_id] else None
942+
end = CommonUtil.tc_nums[run_id].index(rang.stop) if rang.stop in CommonUtil.tc_nums[run_id] else None
948943
if start is None and end is None:
949944
continue
950945
if start is None and target <= end:
951-
return True
946+
continue
952947
if end is None and start <= target:
953948
return True
949+
if start <= target <= end:
950+
return True
954951

955952
return False
956953

957954

958955
def run_test_case(
959-
all_testcases_info,
960956
TestCaseID,
961957
sModuleInfo,
962958
run_id,
@@ -984,12 +980,6 @@ def run_test_case(
984980

985981
# Added this two global variable in CommonUtil to save log information and save filepath of test case report
986982
CommonUtil.error_log_info = ""
987-
# FIXME: Remove these lines
988-
# import random
989-
# CommonUtil.d_day = random.randint(1, 4)
990-
# CommonUtil.d_hours = random.randint(1, 11)
991-
# CommonUtil.d_minutes = random.randint(0, 39)
992-
# CommonUtil.d_seconds = random.randint(0, 50)
993983
ConfigModule.add_config_value("sectionOne", "sTestStepExecLogId", sModuleInfo, temp_ini_file)
994984
create_tc_log_ss_folder(run_id, test_case, temp_ini_file, server_version)
995985
set_important_variables()
@@ -1000,15 +990,10 @@ def run_test_case(
1000990
shared.Set_Shared_Variables("zeuz_prettify_limit", 500)
1001991
CommonUtil.prettify_limit = 500
1002992

1003-
# shared.Set_Shared_Variables("zeuz_automation_log", Path(temp_ini_file).parent.__str__())
1004993
shared.Set_Shared_Variables("zeuz_attachments_dir", (Path(temp_ini_file).parent/"attachments").__str__())
1005994
if not shared.Test_Shared_Variables("element_wait"):
1006995
shared.Set_Shared_Variables("element_wait", 10)
1007996

1008-
# log_line = "# EXECUTING TEST CASE : %s :: %s #" % (test_case, TestCaseName)
1009-
# print("#"*(len(log_line)))
1010-
# CommonUtil.ExecLog("", log_line, 4, False)
1011-
# print("#"*(len(log_line)))
1012997
_color = "white"
1013998
# danger_style = Style(color=_color, blink=False, bold=True)
1014999
table = Table(border_style=_color, box=DOUBLE, expand=False, padding=1)
@@ -1022,7 +1007,7 @@ def run_test_case(
10221007
if performance and browserDriver:
10231008
shared.Set_Shared_Variables("selenium_driver", browserDriver)
10241009

1025-
if check_test_skip(all_testcases_info, run_id, tc_num):
1010+
if check_test_skip(run_id, tc_num):
10261011
sTestStepResultList = ['SKIPPED']
10271012
else:
10281013
sTestStepResultList = run_all_test_steps_in_a_test_case(
@@ -1037,7 +1022,7 @@ def run_test_case(
10371022
debug_info,
10381023
performance
10391024
)
1040-
if check_test_skip(all_testcases_info, run_id, tc_num, False):
1025+
if check_test_skip(run_id, tc_num, False):
10411026
sTestStepResultList[-1] = 'SKIPPED'
10421027

10431028
# TODO: Test case run is completed here somewhere.
@@ -1880,6 +1865,10 @@ def main(device_dict, all_run_id_info):
18801865
CommonUtil.all_logs_json = [each_session]
18811866
CommonUtil.tc_index = 0
18821867
all_testcases_info = each_session["test_cases"]
1868+
if run_id not in CommonUtil.tc_nums:
1869+
CommonUtil.tc_nums[run_id] = []
1870+
for i in [int(i['testcase_no'].split('-')[-1]) for i in all_testcases_info]:
1871+
i not in CommonUtil.tc_nums[run_id] and CommonUtil.tc_nums[run_id].append(i)
18831872
# print("Starting %s with %s test cases" % (CommonUtil.current_session_name, len(all_testcases_info)))
18841873

18851874
for testcase_info in all_testcases_info:
@@ -1980,7 +1969,6 @@ def kill(process):
19801969
except Exception as e:
19811970
print(e)
19821971
run_test_case(
1983-
all_testcases_info,
19841972
test_case_no,
19851973
sModuleInfo,
19861974
run_id,
@@ -2003,7 +1991,6 @@ def kill(process):
20031991

20041992
else:
20051993
run_test_case(
2006-
all_testcases_info,
20071994
test_case_no,
20081995
sModuleInfo,
20091996
run_id,

Framework/Utilities/CommonUtil.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182

183183
processed_performance_data = {}
184184

185+
tc_nums = {}
185186
skip_testcases = {}
186187
global_var = {}
187188
global_sleep = {"selenium":{}, "appium":{}, "windows":{}, "desktop":{}}

0 commit comments

Comments
 (0)