From 2a59fdf76c25d2ff580a07ff31174598e3468726 Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Sat, 1 Mar 2025 22:55:54 +0100 Subject: [PATCH] now extracting the number of tests for gradle as well --- handlers.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/handlers.py b/handlers.py index e0eced1..3bc740d 100644 --- a/handlers.py +++ b/handlers.py @@ -1,5 +1,6 @@ from abc import ABC, abstractmethod import os, re, docker, subprocess +from bs4 import BeautifulSoup USER_ID = os.getuid() # for container user GROUP_ID = os.getgid() @@ -183,6 +184,19 @@ class GradleHandler(BuildHandler): self.updates["n_tests_errors"] = -1 self.updates["n_tests_skipped"] = -1 + # Load the HTML file + with open(os.path.join(self.path, "build/reports/tests/test/index.html"), "r", encoding="utf-8") as file: + soup = BeautifulSoup(file, "html.parser") + + # Extract total tests + self.updates["n_tests"] = int(soup.find("div", class_="infoBox", id="tests").find("div", class_="counter").text.strip()) + + # Extract failed tests + self.updates["n_tests_failed"] = int(soup.find("div", class_="infoBox", id="failures").find("div", class_="counter").text.strip()) + + # Calculate passed tests + self.updates["n_tests_passed"] = self.updates["n_tests"] - self.updates["n_tests_failed"] + def merge_download_lines(lines: list) -> list: """ Merges lines that are part of the same download block in Maven output.