Update generate_static_allure.py
Run Pytest and Serve Report via LocalTunnel / tests (push) Failing after 1m0s
Run Pytest and Serve Report via LocalTunnel / tests (push) Failing after 1m0s
This commit is contained in:
+25
-10
@@ -10,20 +10,20 @@ print("📂 Contenu du dossier allure-report:", os.listdir(ALLURE_DIR))
|
||||
print("📂 Contenu de widgets:", os.listdir(os.path.join(ALLURE_DIR, "widgets")))
|
||||
print("📂 Contenu de data:", os.listdir(os.path.join(ALLURE_DIR, "data")))
|
||||
|
||||
|
||||
DATA_DIR = os.path.join(ALLURE_DIR, "data")
|
||||
WIDGETS_DIR = os.path.join(ALLURE_DIR, "widgets")
|
||||
|
||||
SUITES_CSV = os.path.join(DATA_DIR, "suites.csv")
|
||||
SUITES_JSON = os.path.join(DATA_DIR, "suites.json")
|
||||
SUITES_JSON = os.path.join(WIDGETS_DIR, "suites.json")
|
||||
SUMMARY_JSON = os.path.join(WIDGETS_DIR, "summary.json")
|
||||
TIMELINE_JSON = os.path.join(DATA_DIR, "timeline.json")
|
||||
|
||||
# ------------------- Graph Donut -------------------
|
||||
def generate_donut_chart(df):
|
||||
counts = df['status'].value_counts()
|
||||
def generate_donut_chart(summary):
|
||||
statuses = ['passed', 'failed', 'skipped', 'broken']
|
||||
values = [counts.get(s, 0) for s in statuses]
|
||||
labels = ['✅ Passed', '❌ Failed', '⏭️ Skipped', '💥 Broken']
|
||||
colors = ['#4CAF50', '#F44336', '#FF9800', '#9C27B0']
|
||||
values = [summary.get('stat', {}).get(s, 0) for s in statuses]
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
wedges, _ = ax.pie(values, labels=None, colors=colors, startangle=90, wedgeprops=dict(width=0.4))
|
||||
@@ -39,7 +39,7 @@ def generate_timeline_chart(timeline_data):
|
||||
print("⚠️ Aucune donnée de timeline.")
|
||||
return
|
||||
names = [i["name"].split("/")[-1] for i in items]
|
||||
durations = [i["time"]["duration"] / 1000 for i in items] # ms → s
|
||||
durations = [i["time"]["duration"] / 1000 for i in items]
|
||||
fig, ax = plt.subplots(figsize=(10, max(2, len(names) * 0.3)))
|
||||
ax.barh(names, durations, color="#2196F3")
|
||||
ax.set_xlabel("Durée (s)")
|
||||
@@ -57,7 +57,7 @@ def generate_markdown(suites_csv_df, suites_json_data):
|
||||
f.write("## 📋 Détails des tests\n\n")
|
||||
|
||||
for index, row in suites_csv_df.iterrows():
|
||||
test_id = str(row.get("uid"))
|
||||
test_id = str(row.get("uid", f"unknown-{index}"))
|
||||
name = row.get("name", "Unknown")
|
||||
status = row.get("status", "unknown")
|
||||
duration = row.get("time", 0) / 1000
|
||||
@@ -65,12 +65,11 @@ def generate_markdown(suites_csv_df, suites_json_data):
|
||||
|
||||
json_info = suites_json_data.get(test_id, {})
|
||||
description = json_info.get("description", "")
|
||||
steps = json_info.get("steps", [])
|
||||
parameters = json_info.get("parameters", [])
|
||||
trace = json_info.get("statusTrace", "")
|
||||
|
||||
f.write(f"<details>\n<summary>{name}</summary>\n\n")
|
||||
f.write(f"- **Statut**: {'✅ Passed' if status == 'passed' else '❌ Failed'}\n")
|
||||
f.write(f"- **Statut**: {'✅ Passed' if status == 'passed' else '❌ Failed' if status == 'failed' else status}\n")
|
||||
f.write(f"- **Durée**: {round(duration, 3)} s\n")
|
||||
if description:
|
||||
f.write(f"- **Description**: {description.strip()}\n")
|
||||
@@ -88,11 +87,16 @@ def generate_markdown(suites_csv_df, suites_json_data):
|
||||
# ------------------- Main -------------------
|
||||
def main():
|
||||
try:
|
||||
print(f"📂 Contenu du dossier allure-report: {os.listdir(ALLURE_DIR)}")
|
||||
print(f"📂 Contenu de widgets: {os.listdir(WIDGETS_DIR)}")
|
||||
print(f"📂 Contenu de data: {os.listdir(DATA_DIR)}")
|
||||
|
||||
suites_csv_df = pd.read_csv(SUITES_CSV)
|
||||
with open(SUITES_JSON) as f: suites_json_data = json.load(f)
|
||||
with open(SUMMARY_JSON) as f: summary = json.load(f)
|
||||
with open(TIMELINE_JSON) as f: timeline = json.load(f)
|
||||
|
||||
generate_donut_chart(suites_csv_df)
|
||||
generate_donut_chart(summary)
|
||||
generate_timeline_chart(timeline)
|
||||
generate_markdown(suites_csv_df, suites_json_data)
|
||||
|
||||
@@ -101,5 +105,16 @@ def main():
|
||||
except Exception as e:
|
||||
print("❌ Erreur :", e)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
generate_markdown(suites_csv_df, suites_json_data)
|
||||
|
||||
print("✅ Rapport Markdown généré : static-report.md")
|
||||
|
||||
except Exception as e:
|
||||
print("❌ Erreur :", e)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user