Skip to content

Commit f72f2e5

Browse files
committed
Add new sub-section to the Test Summary called Test Overview
The new Test Overview sub-section shows the number of tests to have passed, failed, and have been skipped, along with the full details from write_report_result_tree(). Signed-off-by: Joachim Wiberg <[email protected]>
1 parent e6ea37f commit f72f2e5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

9pm.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,37 @@ def write_report_project_info(file, config):
389389

390390
file.write("|===\n")
391391

392+
def write_report_test_info(file, data):
393+
pass_count = 0
394+
fail_count = 0
395+
skip_count = 0
396+
397+
def count_tests(suite_data):
398+
nonlocal pass_count, fail_count, skip_count
399+
for test in suite_data['suite']:
400+
if 'result' in test:
401+
if test['result'] == 'pass':
402+
pass_count += 1
403+
elif test['result'] == 'fail':
404+
fail_count += 1
405+
elif test['result'] == 'skip':
406+
skip_count += 1
407+
if 'suite' in test:
408+
count_tests(test)
409+
410+
count_tests(data)
411+
412+
file.write("\n=== Test Overview\n\n")
413+
file.write('[cols="1h,2", width=30%]\n')
414+
file.write("|===\n")
415+
file.write(f"| [.pass]#PASS# | {pass_count}\n")
416+
file.write(f"| [.fail]#FAIL# | {fail_count}\n")
417+
file.write(f"| [.skip]#SKIP# | {skip_count}\n")
418+
file.write("|===\n")
419+
420+
includes = []
421+
write_report_result_tree(file, includes, data, 0)
422+
392423
def write_report(data, config):
393424
with open(os.path.join(LOGDIR, 'report.adoc'), 'a') as file:
394425
current_date = datetime.now().strftime("%Y-%m-%d")
@@ -407,6 +438,7 @@ def write_report(data, config):
407438
file.write("\n<<<\n")
408439
file.write("\n== Test Summary\n\n")
409440
write_report_project_info(file, config)
441+
write_report_test_info(file, data)
410442

411443
file.write("\n<<<\n")
412444
file.write("\n== Test Result\n\n")

0 commit comments

Comments
 (0)