Skip to content

Commit

Permalink
fix result printer
Browse files Browse the repository at this point in the history
  • Loading branch information
ShockedPlot7560 committed Dec 18, 2023
1 parent 92d30f8 commit 022d523
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/framework/result/printer/TestResultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,25 @@ public function print(\Logger $logger) : void {
}

private function printFatal(\Logger $logger): void {
if(count($errors = $this->resultsBag->getFatalErrors()) === 0){
return;
}
$logger->error("Fatal errors occurred during tests:");
$i = 0;
foreach ($this->resultsBag->getFatalErrors() as $error) {
foreach ($errors as $error) {
$errorString = ++$i . ") " . $this->errorToString($error);
$logger->error($errorString);
$logger->logException($error->throwable);
}
}

private function printFailed(\Logger $logger) : void {
if(count($errors = $this->resultsBag->getFailedTests()) === 0){
return;
}
$logger->emergency("Failed tests:");
$i = 0;
foreach ($this->resultsBag->getFailedTests() as $error) {
foreach ($errors as $error) {
$errorString = ++$i . ") " . $this->errorToString($error);
$logger->emergency($errorString);
}
Expand All @@ -44,10 +50,11 @@ private function printStats(\Logger $logger) : void {
$logger->notice("Total tests: " . count($this->resultsBag->getAllTests()));
$logger->notice("Passed tests: " . count($passedTests) . " (" . $this->resultsBag->getSuccessRate() . "%)");
$logger->info((count($failedTests) > 0 ? "§4" : "") . "Total failed: " . count($failedTests) . " (" . $this->resultsBag->getFailedRate() . "%)");
$logger->info((count($fatalErrors) > 0 ? "§c" : "") . "Total fatal: " . count($fatalErrors) . " (" . $this->resultsBag->getFatalRate() . "%)");

$heatmap = new HeatmapCalculator($this->resultsBag);
$logger->info($heatmap->calculateHeatmap());
$logger->info(
(count($fatalErrors) > 0 ? "§c" : "") . "Total fatal: " . count($fatalErrors) . " (" . $this->resultsBag->getFatalRate() . "%)\n" .
"Heatmap: §a" . $this->resultsBag->getSuccessRate() . "% §c" . $this->resultsBag->getFailedRate() . "% §4" . $this->resultsBag->getFatalRate() . "%\n" .
(new HeatmapCalculator($this->resultsBag))->calculateHeatmap()
);
}

private function errorToString(FatalTest|FailedTest $error) : string {
Expand Down

0 comments on commit 022d523

Please sign in to comment.