Skip to content

Commit

Permalink
Merge pull request #318 from jwpage/add-random-order-seed
Browse files Browse the repository at this point in the history
Add random order seed to test recap
  • Loading branch information
nunomaduro authored Jan 23, 2025
2 parents 82cb937 + 985a1d8 commit 940a4f4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Adapters/Phpunit/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\IncompleteTestError;
use PHPUnit\Framework\SkippedWithMessageException;
use PHPUnit\Runner\TestSuiteSorter;
use PHPUnit\TestRunner\TestResult\TestResult as PHPUnitTestResult;
use PHPUnit\TextUI\Configuration\Registry;
use ReflectionClass;
Expand Down Expand Up @@ -268,6 +269,16 @@ public function writeRecap(State $state, Info $telemetry, PHPUnitTestResult $res
),
]);

$configuration = Registry::get();
if ($configuration->executionOrder() === TestSuiteSorter::ORDER_RANDOMIZED) {
$this->output->writeln([
sprintf(
' <fg=gray>Random Order Seed:</> <fg=default>%s</>',
$configuration->randomOrderSeed(),
),
]);
}

$this->output->writeln('');
}

Expand Down
21 changes: 21 additions & 0 deletions tests/Unit/Adapters/PhpunitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,27 @@ public function itHasRecap(): void
'Tests: 2 deprecated, 2 warnings, 1 risky, 1 incomplete, 2 notices, 1 todo, 1 skipped, 9 passed (16 assertions)',
$output
);

$this->assertConsoleOutputNotContainsString(
'Random Order Seed:',
$output
);
}

#[Test]
public function itHasRecapWithRandomOrderSeed(): void
{
$output = $this->runCollisionTests([
'--order-by=random',
'--random-order-seed=123',
'--exclude-group',
'fail,environmentTesting,environmentCustomVariables',
]);

$this->assertConsoleOutputContainsString(
'Random Order Seed: 123',
$output
);
}

#[Test]
Expand Down

0 comments on commit 940a4f4

Please sign in to comment.