From ac55d0412bf6c4c3b37e630323c9491fa2b1c4c3 Mon Sep 17 00:00:00 2001 From: Dmitriy Derepko Date: Sat, 20 Dec 2025 15:57:26 +0400 Subject: [PATCH] chore: make errors more informative --- tests/Acceptance/App/TestCase.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/Acceptance/App/TestCase.php b/tests/Acceptance/App/TestCase.php index 1ebc12d5..e17d29da 100644 --- a/tests/Acceptance/App/TestCase.php +++ b/tests/Acceptance/App/TestCase.php @@ -6,8 +6,6 @@ use Google\Protobuf\Timestamp; use PHPUnit\Framework\SkippedTest; -use PHPUnit\Framework\SkippedWithMessageException; -use PHPUnit\Framework\TestStatus\Skipped; use Psr\Log\LoggerInterface; use Spiral\Core\Container; use Spiral\Core\Scope; @@ -36,16 +34,16 @@ protected function setUp(): void protected function runTest(): mixed { - $c = ContainerFacade::$container; + $container = ContainerFacade::$container; /** @var State $runtime */ - $runtime = $c->get(State::class); + $runtime = $container->get(State::class); $feature = $runtime->getFeatureByTestCase(static::class); // Configure client logger $logger = LoggerFactory::createClientLogger($feature->taskQueue); $logger->clear(); - return $c->runScope( + return $container->runScope( new Scope(name: 'feature', bindings: [ Feature::class => $feature, static::class => $this, @@ -62,7 +60,15 @@ function (Container $container): mixed { return parent::runTest(); } catch (\Throwable $e) { if ($e instanceof TemporalException) { - echo "\n=== Workflow history for failed test {$this->name()} ===\n"; + echo \sprintf( + "\n=== En error occurred while testing %s: %s (%s) ===\n", + static::class . '::' . $this->name(), + $e->getMessage(), + $e::class, + ); + echo "\n=== Stack trace ===\n"; + echo $e->getTraceAsString(); + echo "\n=== Workflow history ===\n"; $this->printWorkflowHistory($container->get(WorkflowClientInterface::class), $args); $logRecords = $container->get(ClientLogger::class)->getRecords(); @@ -117,9 +123,7 @@ private function printWorkflowHistory(WorkflowClientInterface $workflowClient, a ? 0 : $ts->getSeconds() + \round($ts->getNanos() / 1_000_000_000, 6); - foreach ($workflowClient->getWorkflowHistory( - $arg->getExecution(), - ) as $event) { + foreach ($workflowClient->getWorkflowHistory($arg->getExecution()) as $event) { $start ??= $fnTime($event->getEventTime()); echo "\n" . \str_pad((string) $event->getEventId(), 3, ' ', STR_PAD_LEFT) . ' '; # Calculate delta time