Add generate_test_summary.py

This commit is contained in:
2025-07-08 15:13:41 +02:00
parent 678f7e8b13
commit fb3a668e8d
+36
View File
@@ -0,0 +1,36 @@
import glob
import json
from collections import defaultdict
# Statuts possibles
statuses = ['passed', 'failed', 'broken', 'skipped', 'unknown']
results = defaultdict(lambda: defaultdict(int))
totals = defaultdict(int)
# Analyse des fichiers JSON d'Allure
for f in glob.glob('allure-results/*-result.json'):
with open(f) as j:
data = json.load(j)
status = data.get('status', 'unknown').lower()
full_name = data.get('fullName', 'unknown')
test_file = next((part for part in full_name.split('.') if part.startswith('test_')), 'unknown')
results[test_file][status] += 1
totals[status] += 1
# Création du fichier Markdown
with open('ci-reports/markdown/test-summary.md', 'w') as out:
out.write('# Test Summary by File\n\n')
out.write('| File | Passed | Failed | Broken | Skipped | Unknown |\n')
out.write('|------|--------|--------|--------|---------|---------|\n')
for file in sorted(results):
row = [file]
for s in statuses:
row.append(str(results[file].get(s, 0)))
out.write('| ' + ' | '.join(row) + ' |\n')
# Résumé global à la fin
out.write('\n## Total Summary\n\n')
out.write('| Status | Count |\n')
out.write('|---------|-------|\n')
for s in statuses:
out.write(f'| {s.capitalize():<7} | {totals[s]} |\n')