From f730a186ce0ec2cd0f9a1aed21faf7f9b79b452c Mon Sep 17 00:00:00 2001 From: Paul Sochiera <94740279+mudandstars@users.noreply.github.com> Date: Sun, 25 Oct 2026 19:31:09 +0100 Subject: [PATCH] test(shard): cover module test classes outside the tests directory (#1689) * test(shard): cover module test classes outside the tests directory Co-Authored-By: Claude Opus 5.5 (1M context) * chore: refresh the snapshot counts --------- Co-authored-by: Paul Sochiera Co-authored-by: Claude Opus 5.5 (1M context) Co-authored-by: Punyapal Shah --- tests/.snapshots/success.txt | 3 ++- tests/Unit/Plugins/Shard.php | 22 ++++++++++++++++++++++ tests/Visual/Parallel.php | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index f216215d..fd069671 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -1860,6 +1860,7 @@ ✓ parseListTestsOutput → it deduplicates repeated class names from multiple test methods ✓ parseListTestsOutput → it returns an empty list for output with no matching lines ✓ parseListTestsOutput → it parses non-Tests namespaced classes + ✓ parseListTestsOutput → it parses module test classes living outside the tests directory ✓ parseListTestsOutput → it parses unnamespaced top-level classes ✓ parseListTestsOutput → it strips the P\ Pest prefix but keeps the rest of the FQCN ✓ parseListTestsOutput → it ignores junk lines that lack the " - …::" framing @@ -2273,4 +2274,4 @@ ✓ pass with dataset with ('my-datas-set-value') ✓ within describe → pass with dataset with ('my-datas-set-value') - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1612 passed (3518 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1613 passed (3519 assertions) \ No newline at end of file diff --git a/tests/Unit/Plugins/Shard.php b/tests/Unit/Plugins/Shard.php index 54664848..acdb9e7e 100644 --- a/tests/Unit/Plugins/Shard.php +++ b/tests/Unit/Plugins/Shard.php @@ -376,6 +376,28 @@ OUT; ]); }); + it('parses module test classes living outside the tests directory', function (): void { + $output = new BufferedOutput; + $shard = new Shard($output); + + $reflection = new ReflectionClass($shard); + $method = $reflection->getMethod('parseListTestsOutput'); + + $listOutput = <<<'OUT' + INFO Available tests: + + - P\Tests\Unit\Foo::__pest_evaluable_it_works + - P\Modules\Example\tests\ShardModuleExample::__pest_evaluable_module_test_is_listed + - P\Modules\Billing\Tests\Feature\InvoiceTest::__pest_evaluable_it_creates_invoices +OUT; + + expect($method->invoke($shard, $listOutput))->toBe([ + 'Tests\\Unit\\Foo', + 'Modules\\Example\\tests\\ShardModuleExample', + 'Modules\\Billing\\Tests\\Feature\\InvoiceTest', + ]); + }); + it('parses unnamespaced top-level classes', function (): void { $output = new BufferedOutput; $shard = new Shard($output); diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 45cb7fe7..6f42099a 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -20,7 +20,7 @@ test('parallel', function () use ($run): void { $output = $run('--exclude-group=integration'); $output = implode("\n", array_slice(explode("\n", (string) $output), -10)); - $expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1593 passed (3460 assertions)'; + $expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1594 passed (3461 assertions)'; expect($output) ->toContain("Tests: {$expected}")