nunomaduro / collision

💥 Collision is a beautiful error reporting tool for command-line applications
https://nunomaduro.com
MIT License
4.49k stars 156 forks source link

php artisan test --profile not printing results (profileSlowTests in DefaultPrinter) #309

Open stephenstack opened 1 month ago

stephenstack commented 1 month ago

I have never been able to get php artisan test --profile working. I dug deep today and i ended up in vendor/nunomaduro/collision/src/Adapters/Phpunit/Printers/DefaultPrinter.php

on line 422, when I move $this->style->writeSlowTests($this->profileSlowTests, $event->telemetryInfo()); outside the IF block, I get profile results as expected.

Seems to me, that $failed = !Facade::result()->wasSuccessful(); does return TRUE on line 414 as expected BUT The IF on line 421 negates the $failed to evaluate the true as false, thus failing the check, thus the profile results are not printed. See full block below.

If this is the issue, i'll PR it, or am i missing something obvious?

    if (class_exists(Result::class)) {
        $failed = Result::failed(Registry::get(), Facade::result());
    } else {
        $failed = !Facade::result()->wasSuccessful();
     }

    $this->style->writeErrorsSummary($this->state);

    $this->style->writeRecap($this->state, $event->telemetryInfo(), $result);

    if (!$failed && count($this->profileSlowTests) > 0) {
        $this->style->writeSlowTests($this->profileSlowTests, $event->telemetryInfo());
    }
stephenstack commented 1 month ago

@nunomaduro lots of open issues and PRs here. I'm happy to open a PR for the above issue, but are you able to review? 🙏