diff --git a/core/result_handler.py b/core/result_handler.py index 61dfd5466..d86486d4b 100644 --- a/core/result_handler.py +++ b/core/result_handler.py @@ -30,6 +30,12 @@ def _get_output(cls, test_results: dict, colorify: bool, """ cls.result = "Table:\n" + dcount = 0 + ndcount = 0 + dpass = 0 + ndpass = 0 + dtest = 0 + ndtest = 0 for item in test_results: if colorify: @@ -40,13 +46,41 @@ def _get_output(cls, test_results: dict, colorify: bool, table = PrettyTable( ['Volume Type', 'Test Result', 'Time taken (sec)']) + + if test_results[item][0]['tcNature'] == 'disruptive': + dtest += 1 + elif test_results[item][0]['tcNature'] == 'nonDisruptive': + ndtest += 1 for each_vol_test in test_results[item]: table.add_row( [each_vol_test['volType'], each_vol_test['testResult'], each_vol_test['timeTaken']]) - cls.result = (f"{cls.result}{str(table)}\n") + if each_vol_test['tcNature'] == 'disruptive': + dcount += 1 + if each_vol_test['testResult'] == 'PASS': + dpass += 1 + elif each_vol_test['tcNature'] == 'nonDisruptive': + ndcount += 1 + if each_vol_test['testResult'] == 'PASS': + ndpass += 1 + + cls.result = (f"{cls.result}{str(table)}\n\n") + + table = PrettyTable(['Category', + 'Cases', + 'Pass Percent']) + + table.add_row(['nonDisruptive', ndtest, + 0 if ndcount == 0 else (ndpass/ndcount)*100]) + table.add_row(['Disruptive', dtest, + 0 if dcount == 0 else (dpass/dcount)*100]) + table.add_row(['Total', ndtest+dtest, + (0 if (ndcount + dcount == 0) + else ((ndpass + dpass)/(ndcount + dcount))*100)]) + + cls.result = (f"Summary:\n{str(table)}\n{cls.result}\n") cls.result = (f"{cls.result}\nFramework runtime : {total_time}\n") @@ -99,17 +133,64 @@ def store_results_in_excelsheet(cls, excel_sheet: str, test_results: dict, result_sheet = wb.add_sheet('Result Sheet') + dcount = 0 + ndcount = 0 + dpass = 0 + ndpass = 0 + dtest = 0 + ndtest = 0 + + for item in test_results: + if test_results[item][0]['tcNature'] == 'disruptive': + dtest += 1 + elif test_results[item][0]['tcNature'] == 'nonDisruptive': + ndtest += 1 + + for each_vol_test in test_results[item]: + + if each_vol_test['tcNature'] == 'disruptive': + dcount += 1 + if each_vol_test['testResult'] == 'PASS': + dpass += 1 + elif each_vol_test['tcNature'] == 'nonDisruptive': + ndcount += 1 + if each_vol_test['testResult'] == 'PASS': + ndpass += 1 + row = 0 style = xlwt.easyxf('font: bold 1') - result_sheet.write(row, 0, 'Total time taken (s)', style) - result_sheet.write(row, 1, total_time) + result_sheet.write(row, 0, 'Category', style) + result_sheet.write(row, 1, 'Cases', style) + result_sheet.write(row, 2, 'Pass Percent', style) + + row += 1 + result_sheet.write(row, 0, 'nonDisruptive') + result_sheet.write(row, 1, ndtest) + result_sheet.write(row, 2, + 0 if ndcount == 0 + else (ndpass/ndcount)*100) + row += 1 + result_sheet.write(row, 0, 'Disruptive') + result_sheet.write(row, 1, dtest) + result_sheet.write(row, 2, + 0 if dcount == 0 + else (dpass/dcount)*100) - test_case_count = len(test_results) - result_sheet.write(row, 0, 'Total number of TCs', style) - result_sheet.write(row, 1, test_case_count) row += 1 + result_sheet.write(row, 0, 'Total') + result_sheet.write(row, 1, ndtest + dtest) + result_sheet.write(row, 2, + (0 if (ndcount + dcount == 0) + else + ((ndpass + dpass)/(ndcount + dcount))*100)) + + row += 2 + + result_sheet.write(row, 0, 'Total time taken (s)', style) + result_sheet.write(row, 1, total_time) + row += 2 for item in test_results: result_sheet.write(row, 0, item, style) diff --git a/core/test_list_builder.py b/core/test_list_builder.py index c9058d6db..3a00059ad 100644 --- a/core/test_list_builder.py +++ b/core/test_list_builder.py @@ -81,6 +81,7 @@ def create_test_dict(cls, path: str, excluded_tests: list, test_dict["componentName"] = test_case_path.split("/")[-2] test_dict["testClass"] = cls._get_test_class(test_case_path) test_dict["testType"] = test_case_path.split("/")[-3] + test_dict["tcNature"] = test_flags["tcNature"] if test_flags["tcNature"] == "disruptive": for vol_type in test_flags["volType"]: if vol_type not in valid_vol_types: diff --git a/core/test_runner.py b/core/test_runner.py index 9e092354e..09b045178 100644 --- a/core/test_runner.py +++ b/core/test_runner.py @@ -201,6 +201,7 @@ def _run_test(cls, test_dict: dict): test_stats = runner_thread_obj.run_thread() test_stats['timeTaken'] = time.time() - start + test_stats['tcNature'] = test_dict['tcNature'] result_text = f"{test_dict['moduleName'][:-3]}-{test_dict['volType']}" if test_stats['testResult']: test_stats['testResult'] = "PASS"